hammer
August 30, 2013, 11:41am
#1
Basiclly, All Chinese characters are all in wrong state when passed into js environment. But others remain in good state like English characters.
For Example:
I pass the string “测试调用” I will get “æµè¯è°ç¨” in js.
I invoke js like this:
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSString* str = JS_NewStringCopyN(cx, value.c_str(), value.length()); jsval v = STRING_TO_JSVAL(str); jsval ret; JS_CallFunction(cx, someobj, somefunc, 1, v, &ret);
Can someone give me any advice?
hammer
September 2, 2013, 7:21am
#2
This is a really big problem if you can’t read any Chinese characters into js.
hammer
September 3, 2013, 10:33am
#3
After some tests, I figured out that if I pass all data with unicode format. It will work.
utf-8 is not working. It’s very sad, but at least there is a way to solve the problem.
hammer
September 4, 2013, 2:46am
#4
finally, i found c_string_to_jsval can work very well.
lp43
September 7, 2013, 6:22pm
#5
hammer hammer wrote:
finally, i found c_string_to_jsval can work very well.
The same reason with this page: