What is the ASCII number for the double quote? (")
Also, is there a link to a list anywhere?
Finally, how do you enter it in the C family (esp. C#)
The ASCII code for the quotation mark is 34.
There are plenty of ASCII tables on the web. Note that some describe the standard 7-bit ASCII code, while others describe various 8-bit extensions that are super-sets of ASCII.
To put quotation marks in a string, you escape it using a backslash:
string msg = "Let's just call it a \"duck\" and be done with it.";
To put a quotation mark in a character literal, you don't need to escape it:
char quotationMark = '"';
Note: Strings and characters in C# are not ASCII, they are Unicode. As Unicode is a superset of ASCII the codes are still usable though. You would need a Unicode character table to look up some characters, but an ASCII table works fine for the most common characters.
It's 34. And you can find a list on Wikipedia.
yes, the answer the 34
In order to find the ascii value for special character and other alpha character I'm writing here small vbscript. In a note pad, write the below script save as abc.vbs(any name with extention .vbs) double click on the file to execute and you can see double quotes for 34.
For i=0 to 150
msgbox i&"="&char(i)
next
you are never going to need only 1 quote, right?
so I declare a CHAR variable i.e
char DoubleQuote;
then drop in a double quote
Convert.ToChar(34);
so use the variable DoubleQuote where you need it
works in SQL to generate dynamic SQL but there you need
DECLARE #SingleQuote CHAR(1)
and
SET #SingleQuote=CHAR(39)
Related
I have the following line in a plugin to display page views on my Jekyll site:
html = pv.to_s.reverse.gsub(/...(?=.)/,'\& ').reverse
It adds space between thousands, for example 23 678.
How can I add hair space instead of regular space in this string?
In HTML is a so-called decimal numeric character reference:
The ampersand must be followed by a "#" (U+0023) character, followed by one or more ASCII digits, representing a base-ten integer that corresponds to a Unicode code point that is allowed according to the definition below. The digits must then be followed by a ";" (U+003B) character.
Ruby has the \u escape sequence. However it expects the following characters to represent a hexadecimal (base-sixteen) integer. That's 200A. You also have to use a double-quoted string literal which means now the \ character needs to be escaped with another one:
"\\&\u200A"
Alternatively just use it directly:
'\& '
I am pushing some strings to a CSV file:
csv_string = CSV.generate({col_sep: ";", row_sep: "\n"}) do |csv|
csv << ["101-41", "Sparri, \"Violet\" (rod) (1 bunt á 10 stk.)"]
end
When the CSV file is finally generated a regular Excel installation will display the content apparently correctly, but a closer look through a plain text editor (like Sublime Text) shows that the double quotes create confusion:
10-41;"Sparri, ""Violet"" (rod) (1 bunt á 10 stk.)"
How can I avoid this? Should I convert double quotes into something different before pushing to the CSV file?
This is correct, a double quote is escaped with another double quote. From RFC 4180:
If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example:
"aaa","b""bb","ccc"
CSV is no offical standard, strange as it is.
There are the RFC 4180 guidelines that state about double quotes
5. Each field may or may not be enclosed in double quotes (however
some programs, such as Microsoft Excel, do not use double quotes
at all). If fields are not enclosed with double quotes, then
double quotes may not appear inside the fields. For example:
"aaa","bbb","ccc" CRLF
zzz,yyy,xxx
6. Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes. For example:
"aaa","b CRLF
bb","ccc" CRLF
zzz,yyy,xxx
7. If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example:
"aaa","b""bb","ccc"
So your formatting is correct and aslong as Excel shows the file correctly I wouldn't mind about the double "double quotes"
I have an html file that I need to replace some characters with html entities. Right now I'm trying to replace — with — but when I use the Replace All button, the result is that all of those instances of — are replaced with —mdash;
I thought maybe escaping the "&" will work, so I changed the Replace with value to \— but that just results in \—mdash;
The strange thing is that if I go to each, one by one, i.e., click Next, then click Replace, and so on, then it replaces it correctly.
Is this a bug in MacVim? Or am I missing something?
Enter into command line:
:%s/—/\—/g
Also it's possible to get character code. Place your cursor on the character and press ga. Use decimal, hex or octal code into replacement string:
\%d match specified decimal character
\%x match specified hex character
\%o match specified octal character
\%u match specified multibyte character
\%U match specified large multibyte character
:%s/\%d8212/\$mdash;/g
Is it possible to store unescaped markdown documents in yaml? I've tested
key:|+
markdown text block that could have any combination of line breaks, >, -, :, ', " etc etc.
This does not work. I need something like CDATA or python style triple-quotes for yamal. Any ideas?
In literal style of scalar type (what you used in example) line brakes needs still to be "escaped" (in this case intended correctly).
And you can only have printable characters.
I am not fammiliar with markdown, but in case you would need to save unprintable characters, you would definitelly to escape them.
From Yaml specification:
To ensure readability, YAML streams
use only the printable subset of the
Unicode character set. The allowed
character range explicitly excludes
the C0 control block #x0-#x1F (except
for TAB #x9, LF #xA, and CR #xD which
are allowed), DEL #x7F, the C1 control
block #x80-#x9F (except for NEL #x85
which is allowed), the surrogate
block #xD800-#xDFFF, #xFFFE, and #xFFFF.
On input, a YAML processor must accept
all Unicode characters except those
explicitly excluded above.
On output, a YAML processor must only
produce acceptable characters. Any
excluded characters must be presented
using escape sequences.
I have the following string "\u3048\u3075\u3057\u3093". I got the string
from a web page as part of returned data in JSONP.
What is that? It looks like UTF8, but then should it look like "U+3048U+3075U+3057U+3093"?
What's the meaning of the backslashes (\)?
How can I convert it to a human-readable form?
I'm looking to a solution with Ruby, but any explanation of what's going on here is appreciated.
The U+3048 syntax is normally used to represent the Unicode code point of a character. Such code point is fixed and does not depend on the encoding (UTF-8, UTF-32...).
A JSON string is composed of Unicode characters except double quote, backslash and those in the U+0000 to U+001F range (control characters). Characters can be represented with a escape sequence starting with \u and followed by 4 hexadecimal digits that represent the Unicode code point of the character. This is the JavaScript syntax (JSON is a subset of it). In JavaScript, the backslash is used as escape char.
It is Unicode, but not in UTF-8, it is in UTF-16. You might ignore surrogate pairs and deem it as 4-digit hexadecimal code points of a Unicode code character.
Using Ruby 1.9:
require 'json'
puts JSON.parse("[\"\\u4e00\",\"\\u4e8c\"]")
Prints:
一
二
Unicode characters in JSON are escaped as backslash u followed by four hex digits. See the string production on json.org.
Any JSON parser will convert it to the correct representation for your platform (if it doesn't, then by definition it is not a JSON parser)