Subj : Re: About Unicode To : netscape.public.mozilla.jseng From : Jens Thiele Date : Tue Nov 23 2004 12:13 pm ucJun Kim schrieb: > Do you mean that in order to get the result I expect, > should I use JS_CompileUCScript() instead of JS_CompileScript()? yes > Well, I did try and failed. > Since JS_CompileUCScript() functions gets jschar instead of char, > I did some conversion, char -> JSString -> jschar, > and passed it to JS_CompileUCScript() as such... You have to do the right conversion. For JS_NewString there is also JS_NewUCString (if you call JS_NewString the C-string you pass is again interpreted as iso-latin-1) see also: "Handling Unicode" http://www.mozilla.org/js/spidermonkey/apidoc/jsguide.html => you always use the UC functions btw. i did not do this myself yet (in fact at the moment i always ignore hals of the string ;-) but the idea is: you must convert your input from whatever encoding you use to utf-16 and then again the output from utf-16 to whatever encoding you use Shanti Rao posted conversion code for utf-8<->ucs-2 http://groups.google.de/groups?selm=cj8ghg%24s0h2%40ripley.netscape.com Perhaps Shanti will jump in and explain it and the difference between ucs-2 and utf-16 ;-) attention: "ECMA and SpiderMonkey do not do anything special about Unicode characters that don't fit in the first plane; such characters will require more than one jschar, and will result in overlong string lengths." all about unicode: http://www.unicode.org/ http://www.unicode.org/faq/ UTF-8 and Unicode FAQ for Unix/Linux http://www.cl.cam.ac.uk/~mgk25/unicode.html Greetings Jens .