Questions tagged [escaping]

Escaping is the process of applying an alternate meaning to a character or set of characters.

Escaping is used for many purposes, such as providing representations of unprintable characters, changing font colors in terminals, or allowing the inclusion in a string of a character normally used to terminate the string, as well as allowing to output a character to user when that character can be used as a control or markup character.

Some of the more common uses of escaping

  • URL encoding to allow including characters such as / or ?, and others, in URL queries;
  • XML and HTML entities that can be used to encode special characters that, for example, would normally be used for markup purposes.
8924 questions
4
votes
3 answers

How to access object in php when the identifier starts with a @ symbol?

I have a json object that looks like this: {#119130 ▼ +"@id": "1EBEF5DA" +"@name": "The" +"@renewal": "xxxxx" +"@languages": "Eng" } How do I access a the JSON data in php when the identifier starts with an @ symbol? For example trying to…
kevinabraham
  • 1,378
  • 4
  • 28
  • 55
4
votes
2 answers

Converting escaped XML entities back into UTF-8

So I've got this UTF-8 string in an XML file: Horrible place. ☠☠☠ And when I feed it to an external application, the funny characters come back escaped as XML entities: Horrible place. ☠☠☠ In Ruby, how do I convert that string…
lambshaanxy
  • 22,552
  • 10
  • 68
  • 92
4
votes
1 answer

Write JSON to a file without writing escape backslashes to file?

I am trying to write code that will write JSON to a file without including the backslashes used to escape the quotes. Currently my output looks like…
M. Stag
  • 79
  • 1
  • 8
4
votes
2 answers

Allow user to pass a separator character by doubling it in C++

I have a C++ function that accepts strings in below format: : [VALUE]; : [VALUE]; ... This is the function: std::wstring ExtractSubStringFromString(const std::wstring String, const std::wstring SubString) { std::wstring S =…
Blueeyes789
  • 543
  • 6
  • 18
4
votes
1 answer

How to "unescape" the output of bash's `printf "%q"`

In bash, you can use printf "%q" to escape the special characters in a string. I've added a line break in the following examples for clarity's sake: $ printf "%q\n" "foo" foo $ printf "%q\n" 'foo$bar' foo\$bar $ printf "%q\n" "foo bar" # Tab…
Xophmeister
  • 8,884
  • 4
  • 44
  • 87
4
votes
3 answers

How does Bash deal with brackets inside of double quoting?

The question is basically, how does bash deal with double quotes and brackets? I couldn't come up with a better example, so apologies about that, but imagine something like this: "$(echo "${foo}")" What happens there? Is ${foo} technically out of…
spalac24
  • 1,076
  • 1
  • 7
  • 16
4
votes
1 answer

encodeForHTMLAttribute vs encodeForJavaScript

I'm trying to identify the difference between encodeForHTMLAttribute and encodeForJavaScript. Still, I couldn't find a scenario where untrusted data is used as javascript data values, which broke the code when escaped with encodeForHTMLAttribute,…
Chamila Wijayarathna
  • 1,815
  • 5
  • 30
  • 54
4
votes
2 answers

URL Percent Encoding (URI Escaping) in Perl

Can anyone tell me where I can find encoding functions like encode("ram@yahoo.com") ==> ram%40yahoo.com and decode("ram%40yahoo.com") ==> ram@yahoo.com Thanks
jeny
  • 111
  • 1
  • 2
  • 3
4
votes
1 answer

U_REGEX_INVALID_CAPTURE_GROUP_NAME error occurs when trying to escape regex characters on Windows only

I recently implemented a function to escape characters interpretable as regex that go into a system call for my R package 'rNOMADS' SanitizeWGrib2Inputs <- function(check.strs) { #Escape regex characters before inputting to wgrib2 #INPUTS …
glossarch
  • 272
  • 5
  • 18
4
votes
2 answers

Why these 5 (6?) characters are considered "unsafe" HTML characters?

In PHP, there is a function called htmlspecialchars() that performs the following substitutions on a string: & (ampersand) is converted to & " (double quote) is converted to " ' (single quote) is converted to ' (only if the flag…
Pedro A
  • 3,989
  • 3
  • 32
  • 56
4
votes
2 answers

How to output two versions of a string, one with escape character and the other not, in C++?

I have one chance to define the string, lets say string s = "abc\"def\\hhh\"i"; After this definition, I want to output (using ofstream to write to a text file) two versions of this string afterwards. The first one is the output of s by…
4
votes
1 answer

How to escape brace in gnu-parallel

I have a python script that I want to call using gnu-parallel this way: parallel run_script.py --outfile=/path/to/somewhere/{}/{}.nc --shift={} ::: 1 2 3 How can I escape the first curly brace in [--outfile] to be used for python string formatting…
Nicolas
  • 43
  • 3
4
votes
7 answers

How to display ;amp& in HTML?

I have to display this exact string in HTML: ;amp& When I try it always changes to "&". How to fix that?
fomicz
  • 1,752
  • 7
  • 25
  • 33
4
votes
3 answers

The ^ gets doubled when sending string as parameter to function in batch script

This is my code: set var1="`netsh int ipv4 show interface ^| findstr /I Network`" call:GetEles %var1% goto:eof :GetEles for /F "tokens=1 usebackq" %%F IN (%~1) do echo %%F goto:eof When I check the command while it is running, the ^ becomes…
lee
  • 87
  • 5
4
votes
4 answers

escaping html tags and reading only the text in php?

I was wondering is there a way to escape all html tags from a a bunch of html code, and extract only the text i.e. this is strong

this is a header

and I want to get the text between the tags only, so basically…
getaway
  • 8,792
  • 22
  • 64
  • 94