1
0
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:
Ykkrosh
2011-02-17 20:08:20 +00:00
parent 4f724056d5
commit 1c7e33b528
69 changed files with 372 additions and 562 deletions
+4 -8
View File
@@ -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))