escaping

how can I enter character “<” in strings.xml?

瘦欲@ 提交于 2019-12-02 10:58:41
I want to enter string " -< " in strings.xml file in eclipse, the string has character < and I couldn't add it to xml file without error! I even tried to escaping by \ character: <string name="search_target_arrow"> -\< </string> or enclosing it between "" as below: <string name="search_target_arrow">" -< "</string> but none worked. Then finally with help of kind users here I found that this would be the correct way to enter such chars in xml: <string name="search_target_arrow"> -&lt; </string> but now when I get this resource in my code: getResources().getString(R.string.search_target_arrow);

Escaped characters in string from submitted form

一曲冷凌霜 提交于 2019-12-02 10:25:25
Every time a POST is made I get escaped characters. \ -> \\ ' -> \' " -> \" I have a multistep form, which transmits the data from one form to another. I save the values with prepared statments in the database. The values in the database currently look like Paul\'s House . User should have the possiblity to use single and double quotes in their string. This is a simple example demonstrating the escaping effect: <?php echo $_POST['value']; ?> <form action="form.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="value" value="Paul's House"> <input type="submit" value=

Storing HTML Within Attribute

為{幸葍}努か 提交于 2019-12-02 10:09:38
问题 I'm storing HTML code within an element attribute like so. <div data-html-code="<iframe width="560" height="315" src="https://www.youtube.com/embed/sNhhvQGsMEc" frameborder="0" allowfullscreen></iframe>"></div> How can I escape all the necessary characters to make this valid using jQuery/Javascript? 回答1: use this htmlEscape method function htmlEscape(str) { return String(str) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/</g, '<') .replace(/>/g, '>'); } this should

Label property to accept escape sequences in C# [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 09:59:05
Possible Duplicate: Enter “&” symbol into a text Label in Windows Forms? Is there any property for a label to display '&' in C#? I'm trying to display customer names in a label. When there is any '&' symbol in the name, it's getting displayed as '_'. For example, A&B XXX is getting displayed as AB with B underlined. Instead of hardcoding, is there any way to display & symbols as received by means of setting any property? The Label control can't display the control characters encoded by escape sequences, and there's no property that controls that. The reason is it draws its text using standard

Escaping double Quotes in String

橙三吉。 提交于 2019-12-02 09:28:58
How do i escape double quotes in string in Grails : string = " "12.10 On-Going Submission of ""Made Up"" Samples." " I have tried alot of methods //text : artifact.text.encodeAsJavaScript(), //text: artifact.text.encodeAsHTML(), //text: StringEscapeUtils.escapeJava((String)artifact.text), //got an error when doing this //text: artifact.text.replaceAll("\" "," \\\\" "), None of the above worked for me. You can refer to question posted by for understanding myproblem here and here too the error (json stops at "\\"12.10 On-Going Submission o\\"\\""): 014-09-25 12:15:21,869 [http-bio-8080-exec-3]

Escaping backslashes in string

只愿长相守 提交于 2019-12-02 09:26:56
问题 I would like to know what is a good way to escape back slashes in a string without adding unnecessary slashes to it. I mean, usually if I want to escape a backslash in a string, the simplest way is to use String.Replace() like so: string s = someString.Replace("\\", "\\\\"); A similar thing can be done with regular expressions using Regex.Replace() . Now my question is, lets say I have a string that has some of its back slashes escaped like for example: "C:\some_folder\\some_file.bin" Now if

Getting illegal character range in regex :java

对着背影说爱祢 提交于 2019-12-02 09:19:26
问题 I have a simple regex pattern that verifies names. But When I run it I get illegal character range error. I thought by escaping "\s" it will allow a space but the compiler is still complaining. public boolean verifyName(String name) { String namePattern = "^[\\p{L}]++(?:[',-\\s][\\p{L}]++)*+\\.?$"; return name.matches(namePattern); } and this is the error that i think shouldn't be occurring since a name might contain anny of these [',-\\s] so where am i not understanding? 回答1: You can't have

What does the \newline escape sequence mean in python?

痞子三分冷 提交于 2019-12-02 08:56:15
问题 I found the sequence \newline in a list of escape sequences in the python documentation. I wonder how it is used and for what. At least in my interpreter it seems this is just interpreted as '\n' + 'ewline' : >>> print('\newline') ewline 回答1: It refers to the actual newline character - the one with character code "16" (0x10) - not the text sequence "newline". So, an example is like: print("a\ b") Here, the backslash is succeeded by the newline, inside a string, and what is printed is just "ab

How to pass quoted parameters to another program

人走茶凉 提交于 2019-12-02 08:13:55
In a bash script, I need to pass a parameter to another program. The parameter has spaces in so must be quoted. Everything works fine in this simple case 1: /bin/echo /some/command --param="abc def ghi" Output: /some/command --param=abc def ghi The problem begins if I want to make the bash script more sophisticated, somehow the parameter value has changed in case 2 and 3: FOO="ghi" DEFAULTS="--param=\"abc def $FOO\"" /bin/echo /some/command $DEFAULTS DEFAULTS='--param="abc def '$FOO'"' /bin/echo /some/command $DEFAULTS Output: /some/command --param="abc def ghi" /some/command --param="abc def

PHP: How should I escape a string that will be going into a Javascript String?

[亡魂溺海] 提交于 2019-12-02 08:06:15
How should I escape a string that will be going into a Javascript String? URLEncode(X)? str_replace("'","\'",X)? use json_encode so you can do $page_params = array( 'user_logged_in' => $suer->IsActive(), 'some_string' => "sajdhf\"test''z\'\fsdf" 'ts' => time() ); $page_params = json_encode($page_params); then in your template you can just go var page_params = <?php echo $page_params ?>; witch would produce var page_params = {"user_logged_in":false,"some_string":"sajdhf\"test''z\'\fsdf","ts":2452346543} this way you can set multiple variables to 1 string and escaping is done by the Json Library