escaping

How to escape Backslash in Javascript object literal

自闭症网瘾萝莉.ら 提交于 2020-01-11 11:46:27
问题 I know question is asked many times, i gone through with all the questions. but none of them is helping my situation. I have a object literal, for one of the property i assign some string which has backslash charecter, but while reading the property the backslash is getting truncated. I want to use this object literal in JSON.Stringify method. as per JSON, backslash are not allowed. we need to escape it. is there any way ? i cant modify the data to add an extra backslash, because data is

How to echo the literal string “-e” (and nothing else) in bash?

我的梦境 提交于 2020-01-11 09:51:49
问题 How can I echo the literal string -e and nothing else? I'm trying to better understand how shell arguments are escaped. The following commands do not work: echo -e # prints nothing echo '-e' # prints nothing echo "-e" # prints nothing echo \-e # prints nothing echo \\-e # prints \-e echo '\-e' # prints \-e echo "'-e'" # prints '-e' (with quotes) echo -- -e # prints -- -e I can't find one that doesn't either include quotes or a leading slash. 回答1: I'm assuming the real question is why: A C# or

How to write an XML tag with double quotes using command prompt echo command

落爺英雄遲暮 提交于 2020-01-10 05:25:08
问题 Good afternoon, I would like to add the simpliest tag into a file, using a CMD batchfile, but it seems that the double quotes are spoiling the party: From other StackOverflow posts I am aware of the double quote state machine and the usage of ^" (^ as an escape character). Still I can't make it work: Hereby my attempts (with their results): C:\>echo <tag variable="value"> // very naïve The syntax of the command is incorrect. C:\>echo "<tag variable="value">" // let's use quotes for delimiting

Saving an escape character 0x1b in an XML file

 ̄綄美尐妖づ 提交于 2020-01-10 04:34:08
问题 We have an application that communicates with printers using their internal printer fonts. This requires sending some data in a binary format using a font description property. One of the characters to be sent is an escape character (0x1b). The state of the system and all options changed are later saved in an XML file, but when we try to write the value, we get the following exception: System.InvalidOperationException: There is an error in XML document (1009, 26). ---> System.Xml.XmlException

Do I need to escape backslash in a config file?

扶醉桌前 提交于 2020-01-10 03:32:05
问题 I have a config file, myapp.exe.config. In the file I have an attribute with a fullpath filename as the value. <add key="InfoFile" value="c:\temp\info.txt" /> It seems to work if I use a single or double backslash. That is, <add key="InfoFile" value="c:\\temp\\info.txt" /> works also. What is the correct way to do this? 回答1: You don't need that. Anything within an attribute value is character data. Since you're reading these values using C#, they'll get escaped as if they would be a literal

Escaping double quotes with tcsh alias

江枫思渺然 提交于 2020-01-09 11:39:10
问题 I'm trying to run the following commands: replace -x "must " A2input.txt replace -x " a" -f -s ## A2input.txt replace -x to -s ## -a A2input.txt replace -x faith -f "unequivocal" A2input.txt And it'd be nice if I could just alias it to something short and simple like "a", "b", "c", "d", etc... However, some of those arguments have a quote, which is messing up the alias. Does anyone know how to actually escape the double quotes? I've tried things like '\"' and \" but nothing seems to work. I'm

Escaping a dollar sign in Unix inside the cat command

有些话、适合烂在心里 提交于 2020-01-09 09:47:27
问题 On Ubuntu, I would like to end up with a disk file that reads: foo $(bar) I would like to create this file using the cat command, e.g. cat <<EOF > baz.txt type_magic_incantation_here_that_will_produce_foo_$(bar) EOF The problem is the dollar sign. I have tried multiple combinations of backslash, single-quote, and double-quote characters, and cannot get it to work. 回答1: You can use regular quoting operators in a here document: $ cat <<HERE > foo \$(bar) > HERE foo $(bar) or you can disable

How to echo a variable containing an unescaped dollar sign in bash

混江龙づ霸主 提交于 2020-01-09 05:20:07
问题 If I have a variable containing an unescaped dollar sign, is there any way I can echo the entire contents of the variable? For example something calls a script: ./script.sh "test1$test2" and then if I want to use the parameter it gets "truncated" like so: echo ${1} test1 Of course single-quoting the varaible name doesn't help. I can't figure out how to quote it so that I can at least escape the dollar sign myself once the script recieves the parameter. 回答1: The variable is replaced before the

How to escape special characters in PowerShell?

淺唱寂寞╮ 提交于 2020-01-09 03:53:10
问题 When my PowerShell script runs, it prompts the user for a password parameter. That password can contain any number of special characters like *\~;(%?.:@/ That password is then used as a parameter for a .exe command, but it is often incorrect due to some special characters not being escaped properly. An example past password was $(?-.?-(. The only characters I needed to escape was '(', which I replaced with '`(' to make it work. However, that password is now expired. The new password is

decodeURIComponent vs unescape, what is wrong with unescape?

杀马特。学长 韩版系。学妹 提交于 2020-01-09 02:00:28
问题 In answering another question I became aware that my Javascript/DOM knowledge had become a bit out of date in that I am still using escape / unescape to encode the contents of URL components whereas it appears I should now be using encodeURIComponent / decodeURIComponent instead. What I want to know is what is wrong with escape / unescape ? There are some vague suggestions that there is some sort of problem around Unicode characters, but I can't find any definite explanation. My web