javascript - How to type the prime ( ' ) symbol in a string? - Stack Overflow

What is the proper syntax to display 25' as output description?Example:var sizeData = [

What is the proper syntax to display 25' as output description?

Example:

var sizeData = [            
    {description:'Remended sizes listed below', value:'', text:'Select Size'},                   
    {description:'Boat < 25 &prime;, 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'},
];

What is the proper syntax to display 25' as output description?

Example:

var sizeData = [            
    {description:'Remended sizes listed below', value:'', text:'Select Size'},                   
    {description:'Boat < 25 &prime;, 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'},
];
Share Improve this question edited Jan 17, 2013 at 1:21 Felix Kling 818k181 gold badges1.1k silver badges1.2k bronze badges asked Jan 17, 2013 at 1:11 Casey JardinCasey Jardin 211 silver badge4 bronze badges 3
  • 1 That is not JSON! – Bergi Commented Jan 17, 2013 at 1:12
  • The prime character is a distinct Unicode character. You can use it inside a singe-quote encapsulated string normally. – Šime Vidas Commented Jan 17, 2013 at 1:12
  • stackoverflow./questions/2275359/… – woodlumhoodlum Commented Jan 17, 2013 at 1:22
Add a ment  | 

4 Answers 4

Reset to default 3

In a JSON file, where all strings are delimited with double quotes, you can just write apostrophes.

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 "'").

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 &prime;, in both JSON and JavaScript you can replace it with the escape sequence \u2032 if you do not want to use the remended UTF-8 character .

Like so:

foo: '25′'

Notice that the prime character and the apostrophe character are two different Unicode characters. 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:

25′, and 25′′

var sizeData = [
{description:\'Remended sizes listed below\', value:\'\', text:\'Select Size\'},
{description:\'Boat < 25 ′, value:\'size0\', text:\'Size 0\'} ];

You can enclose a (') using a "". Basically like this " ' ".

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744831344a4596103.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信