Unicode

W

WilsonOfCanada

Hellos,

I have a problem with strings converting to unicode that is in a
function.

var list_provinces = ['\\u82F1\\u5C6C','\\u54E5\\u5025']

for (loopCounter=0;loopCounter<(list_provinces.length);loopCounter++)
{

var province = document.createElement('option');

province.text = list_provinces[loopCounter];
province.value = list_provinces[loopCounter];

if (loopCounter == 0)
{
province.selected = "selected";
}

try
{
menuProvince.add(province, null);
}

catch(ex)
{
menuProvince.add(province);
}
}

However, when my list shows up, it only shows
\u82F1\u5C6C
\u54E5\u5025

Thanks
 
R

Richard Cornford

Hellos,

I have a problem with strings converting to unicode that
is in a function.

var list_provinces = ['\\u82F1\\u5C6C','\\u54E5\\u5025']
However, when my list shows up, it only shows

That is correct (as you have it programmed). In a string literal the
backslash is the escaping character. To include a literal backslash in
a sting literal you need to escape the backslash by preceding it with
a backslash, which is precisely what you have done above. However, it
looks like you wanted backslashes to mark the beginning of unicode
escape sequences (rather than for literal backslashes to appear in the
string), in which case you should not have escaped the backslashes.

Richard.
 
W

WilsonOfCanada

Thanks for the reply,

however, it is sent like that as a template from python which the '//'
are automatic.
 
T

Thomas 'PointedEars' Lahn

WilsonOfCanada said:
Thanks for the reply,

Which reply? Please take heed of said:
however, it is sent like that as a template from python which the '//'
are automatic.

There are backslashes, not forward slashes, right? And if the server-side
Python script generates wrong escape sequences for this client-side
ECMAScript script, it would obviously be best to fix the server-side Python
script. (BTDT)


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,089
Messages
2,570,602
Members
47,223
Latest member
smithjens316

Latest Threads

Top