From 7008e5b53cc5fc647dface75c74115b00db8dba4 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Mon, 6 Sep 2004 11:28:30 +0000 Subject: [PATCH] Updated to handle Unicode strings This was SVN commit r1135. --- source/gui/scripting/JSInterface_IGUIObject.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index 432ed16244..49e03eb477 100755 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -1,10 +1,12 @@ -// $Id: JSInterface_IGUIObject.cpp,v 1.14 2004/09/06 02:22:38 gee Exp $ +// $Id: JSInterface_IGUIObject.cpp,v 1.15 2004/09/06 11:28:30 philip Exp $ #include "precompiled.h" #include "JSInterface_IGUIObject.h" #include "JSInterface_GUITypes.h" +#include "ps/StringConvert.h" + JSClass JSI_IGUIObject::JSI_class = { "GUIObject", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub, @@ -162,8 +164,8 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval CGUIString value; GUI::GetSetting(e, propName, value); // Create a garbage-collectable copy of the string - // TODO Gee@Ykkrosh: this was just to make it compile - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (const char*)value.GetRawString().c_str() )); + JSString* s = StringConvert::wchars_to_jsstring(cx, value.GetRawString().c_str()); + *vp = STRING_TO_JSVAL(s); break; } @@ -220,7 +222,9 @@ JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval case GUIST_CGUIString: { - CStr value = JS_GetStringBytes(JS_ValueToString(cx, *vp)); + std::wstring value; + StringConvert::jsstring_to_wstring(JS_ValueToString(cx, *vp), value); + CGUIString str; str.SetValue(value); GUI::SetSetting(e, propName, str);