Turning a single quote into an escaped single quote within a string
Do this so you don’t have to think about it: s = s.Replace(“‘”, @”\'”);
Do this so you don’t have to think about it: s = s.Replace(“‘”, @”\'”);
As a general solution for passing data from Python to Javascript, consider serializing it with the json library (part of the standard library in Python 2.6+). >>> sample = “hello’world” >>> import json >>> print json.dumps(sample) “hello\’world”
This is impossible according to the POSIX standard. This is not a function of a specific shell, PATH handling is done within the execvp function in the C library. There is no provision for any kind of quoting. This is the reason why including certain characters (anything not in the “portable filename character set” – … Read more
Short answer: <%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %> <c:out value=”${myString}”/> there is another option: <%@taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> ${fn:escapeXml(myString)}
regexp.QuoteMeta does the deed.
If it’s part of a Database query you should be able to use a Parameterized SQL Statement. As well as escaping your quotes, this will deal with all special characters and will protect you from SQL injection attacks.
The W3C released an official response about when to use and when not to use character escapes which you can find here. As they are also the group that is in charge of the HTML specification, I think it’s best to follow their advice. From the section “When to Use Escapes” Syntax characters. There are … Read more
Why is \? one of the escape sequence characters? Because it is special. The answer leads to Trigraph, and the C/C++ preprocessor replaces the following three-character sequences with the corresponding single character. (C11 §5.2.1.1 and C++11 §2.3) Trigraph: ??( ??) ??< ??> ??= ??/ ??’ ??! ??- Replacement: [ ] { } # \ ^ … Read more
To add a single quote to a string, you include two ‘ marks e.g. str := ”’test string”’; Writeln(str) In the string above, you have the normal single quotation to start a string and then two for the single quote. Same goes for the end of the string. You can also use # followed by … Read more
The forward slash is valid as is and does not need further encoding. The only reserved characters are: > < & % For even more XML entities – http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references