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 ′, 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 ′, 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
4 Answers
Reset to default 3In 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 ′
, 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条)