escaping

Javascript \\x escaping

纵饮孤独 提交于 2019-11-29 10:56:48
I've seen a few other programs that have something like this: var string = '\x32\x20\x60\x78\x6e\x7a\x9c\x89'; And I had to try to fiddle with the numbers and letters, to find the text I wanted to display. I'm wondering if there is a function to find the \x escape of a string, like string.toUpperCase() in JS. I'm using processing JS, but it will be okay for me to use other programming languages to find the ASCII for \x . arcyqwerty If you have a string that you want escaped, you can use String.prototype.charCodeAt() If you have the code with escapes, you can just evaluate them to get the

JSTL escaping special characters [duplicate]

烂漫一生 提交于 2019-11-29 10:50:04
问题 This question already has an answer here: XSS prevention in JSP/Servlet web application 9 answers I have this weird issue with special characters. In JSP, I am using field name as id and the name can be anything like id="<1 and &>2" (OR) id="aaa & bbb" I don't have any other option to use ID's other than names, that what the only thing I get from backend. So, Is there any logic to remove all the special characters using JSTL. With the present scenario, In JS I will do some operations with

Escape Quotes In HTML5 Data Attribute Using Javascript

泄露秘密 提交于 2019-11-29 10:45:43
问题 I'm using jQuery's .data() to work with custom HTML5 data attributes where the value of the attribute needs to be able to contain both single quotes and double quotes: <p class="example" data-example="She said "WTF" on last night's show."> I know using character codes like " in the data attribute value could make the above work, but I can't always control how the values are inputted. Plus, I need to be able to use HTML tags in the markup, like this: <p class="example" data-example=" She said

How can I scp a file with a colon in the file name?

。_饼干妹妹 提交于 2019-11-29 10:39:01
问题 I'm trying to copy a file using scp in bash with a colon ( : ) character in the source filename. The obfuscated version of my command I'm using is: scp file\:\ name.mp4 user@host:"/path/to/dest" I get this error: ssh: Could not resolve hostname Portal 2: Name or service not known I know I could just rename the file and remove the : , but I'd like to know if it's possible to escape the colon. 回答1: Not quite a bash escaping problem, it's scp treating x: as a [user@]host prefix, try: scp ./file:

what's the escape sequence for hyphen (-) in PostgreSQL

你离开我真会死。 提交于 2019-11-29 10:34:32
问题 I'm trying to rename a database to a name with a hyphen (-). ALTER DATABASE one RENAME TO one-two; And psql returns an error: ERROR: syntax error at or near "-" What should I use as an escape sequence for "-" character or what's the way to do the above? Note: I've tried the '\-' and didn't work as well. Thanks. 回答1: Double quotes should do it. But you'll have to always use the quoted-identifier everywhere you reference the database. ALTER DATABASE one RENAME TO "one-two"; 来源: https:/

javascript - Better Way to Escape Dollar Signs in the String Used By String.prototype.replace

谁都会走 提交于 2019-11-29 10:00:30
I want to replace a string by another. I found when the replaceValue contains "$" , the replace will fail. So I am trying to escape "$" by "$$" first. The code is looks like this: var str = ..., reg = ...; function replaceString(replaceValue) { str.replace(reg, replaceValue.replace(/\$/g, '$$$$')); } But I think it is ugly since I need to write 4 dollar signs. Is there any other charactors that I need to escape? And is there any better way to do this? Leonid There is a way to call replace that allows us not to worry about escaping anything. var str = ..., reg = ...; function replaceString

postgres dblink escape single quote

99封情书 提交于 2019-11-29 09:36:23
Related Link: String literals and escape characters in postgresql Here is my error: ERROR: type "e" does not exist Here is my query: SELECT * FROM dblink('host=theHostName port=1234 dbname=theDBName user=theUser password=thePassword', E'SELECT field_1, CASE WHEN field_2 IS NOT NULL THEN \'inactive\' ELSE \'active\' END AS field_status FROM the_table ') AS linkresults(field_1 varchar(20),field_2 varchar(8)) If I use double quotes, remove the backslash escape for the single quotes and remove the E before the SELECT statement SELECT * FROM dblink('host=theHostName port=1234 dbname=theDBName user

Ruby: Write escaped string to YAML

爱⌒轻易说出口 提交于 2019-11-29 09:35:30
问题 The following... require 'yaml' test = "I'm a b&d string" File.open('test.yaml', 'w') do |out| out.write(test.to_yaml) end ...outputs ... --- this is a b&d string How can I get it to output --- 'this is a b&d string' ??? 回答1: If you want to store an escaped string in YAML, escape it using #inspect before you convert it to YAML: irb> require 'yaml' => true irb> str = %{This string's a little complicated, but it "does the job" (man, I hate scare quotes)} => "This string's a little complicated,

Invalid escape sequence (valid ones are \\b \\t \\n \\f \\r \\\" \\' \\\\ )

不羁的心 提交于 2019-11-29 09:28:41
I am trying to read a file into my Java program using java.util.Scanner and I get the above message when I enter the code below (I am new to java) - can anyone help? (I looked at a similar message someone got with their own code, but it was too complex for me to use in my example!). I have Windows 7. BufferedReader job = new BufferedReader (new FileReader("\My Documents\JOBS\newfile.txt")); You need to escape the "\" in the file path. BufferedReader job = new BufferedReader (new FileReader("\\My Documents\\JOBS\\newfile.txt")); \ is an escape character , use \\ If you're using eclipse, there's

How to escape or terminate an escape sequence in C

时光怂恿深爱的人放手 提交于 2019-11-29 09:27:56
I have sequences of characters I'm feeding to a decoding function: For example: "\x05three" (Yes, that's a Pascal-style string. The function translates length-prefixed strings to null-terminated strings.) I wrote a few test cases, among which: "\x04four" And to my surprise, that came out as "Oour". Looking closer, it turns out that the specification on escape sequences for Visual Studio allows that, my sequence is basically interpreted as \x04f , which would be 79 in base 10 (thus my resulting string becomes "Oour", 79 being 'O') My solution was simply to split the string: "\x04" "four" The