forked from mirrors/0ad
Remove a load of implicit CStr type conversions, since they're error-prone and can cause silent data loss.
Handle most CStr8/CStrW conversions via UTF-8 instead of effectively assuming Latin-1. Return UTF-8 strings from Xeromyces API. This was SVN commit r8929.
This commit is contained in:
@@ -712,8 +712,11 @@ std::wstring ScriptInterface::ToString(jsval obj)
|
||||
return source;
|
||||
}
|
||||
|
||||
CScriptValRooted ScriptInterface::ParseJSON(const utf16string& string)
|
||||
CScriptValRooted ScriptInterface::ParseJSON(const std::string& string_utf8)
|
||||
{
|
||||
std::wstring attrsW = wstring_from_utf8(string_utf8);
|
||||
utf16string string(attrsW.begin(), attrsW.end());
|
||||
|
||||
jsval vp;
|
||||
JSONParser* parser = JS_BeginJSONParse(m->m_cx, &vp);
|
||||
if (!parser)
|
||||
@@ -737,13 +740,6 @@ CScriptValRooted ScriptInterface::ParseJSON(const utf16string& string)
|
||||
return CScriptValRooted(m->m_cx, vp);
|
||||
}
|
||||
|
||||
CScriptValRooted ScriptInterface::ParseJSON(const std::string& string_utf8)
|
||||
{
|
||||
// TODO: we could do more efficient string conversion
|
||||
std::wstring attrsW = wstring_from_utf8(string_utf8);
|
||||
return ParseJSON(utf16string(attrsW.begin(), attrsW.end()));
|
||||
}
|
||||
|
||||
CScriptValRooted ScriptInterface::ReadJSONFile(const VfsPath& path)
|
||||
{
|
||||
if (!FileExists(g_VFS, path))
|
||||
|
||||
Reference in New Issue
Block a user