[英]How to type the prime ( ' ) symbol in a string?
What is the proper syntax to display 25' as output description? 显示25'作为输出描述的正确语法是什么?
Example: 例:
var sizeData = [
{description:'Recommended sizes listed below', value:'', text:'Select Size'},
{description:'Boat < 25 ′, value:'size0', text:'Size 0'},
{description:'25-35 Foot Boat', value:'size2', text:'Size 2'},
{description:'40-45 Foot Boat', value:'size3', text:'Size 3'},
];
In a JSON file, where all strings are delimited with double quotes, you can just write apostrophes. 在JSON文件中,所有字符串都用双引号分隔,您只需编写撇号即可。
In a JavaScript object literal, where you can delimit strings with apostrophes as well, you then will need to escape them with a backslash: '\\''
(dobule quote delimiters: just "'"
). 在JavaScript对象文字中,您还可以在其中用撇号定界字符串,然后将需要使用反斜杠
'\\''
(双引号定界符:只是"'"
)对它们进行转义。
The prime symbol - which is different from the apostrophe you typed - can be inserted without harm. 可以插入素数符号 (与您键入的撇号不同),而不会造成伤害。 Depending on the encoding of your file, you might need to write it a bit different.
根据文件的编码,您可能需要编写一些不同的文件。 In HTML you can replace it with the entity
′
在HTML中,您可以将其替换为实体
′
, in both JSON and JavaScript you can replace it with the escape sequence \′
if you do not want to use the recommended UTF-8 character ′
. ,如果您不想使用建议的UTF-8字符
′
,则可以在JSON和JavaScript中将其替换为转义序列\′
。
Like so: 像这样:
foo: '25′'
Notice that the prime character and the apostrophe character are two different Unicode characters. 请注意, 主要字符和撇号字符是两个不同的Unicode字符。 You can put the prime character inside a single-quote encapsulated string normally.
您通常可以将撇号放在单引号封装的字符串中。
Btw, above the prime character is printed in monospace font. 顺便说一句,在主字符上方以等宽字体打印。 This is how it looks in sans-serif:
这是在sans-serif中的外观:
25′, and 25′′ 25'和25''
var sizeData = [ var sizeData = [
{description:\\'Recommended sizes listed below\\', value:\\'\\', text:\\'Select Size\\'}, {说明:\\'建议的尺寸如下所列\\',值:\\'\\',文字:\\'选择尺寸\\'},
{description:\\'Boat < 25 ′, value:\\'size0\\', text:\\'Size 0\\'} ]; {description:\\'Boat <25',value:\\'size0 \\',text:\\'Size 0 \\'}];
You can enclose a (') using a "". 您可以使用“”括起(')。 Basically like this " ' ".
基本上像这样的“”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.