Changes XMB format to store UTF-8 strings and removes pointless UTF-16 conversions, refs #204, #244.

Bumps XMB version to 2.

This was SVN commit r15309.
This commit is contained in:
historic_bruno
2014-06-08 03:23:37 +00:00
parent 40b351a99a
commit cb9d0733ef
3 changed files with 23 additions and 38 deletions
+7 -9
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2014 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -70,7 +70,7 @@ PSRETURN CXeromyces::Load(const PIVFS& vfs, const VfsPath& filename)
// Arbitrary version number - change this if we update the code and
// need to invalidate old users' caches
u32 version = 1;
u32 version = 2;
VfsPath xmbPath;
Status ret = cacheLoader.TryLoadingCached(filename, MD5(), version, xmbPath);
@@ -277,11 +277,10 @@ static void OutputElement(const xmlNodePtr node, WriteBuffer& writeBuffer,
else
{
// Write length and line number and null-terminated text
utf16string textW = CStr8(text).FromUTF8().utf16();
u32 nodeLen = u32(4 + 2*(textW.length()+1));
u32 nodeLen = u32(4 + text.length()+1);
writeBuffer.Append(&nodeLen, 4);
writeBuffer.Append(&linenum, 4);
writeBuffer.Append((void*)textW.c_str(), nodeLen-4);
writeBuffer.Append((void*)text.c_str(), nodeLen-4);
}
// Output attributes
@@ -290,11 +289,10 @@ static void OutputElement(const xmlNodePtr node, WriteBuffer& writeBuffer,
writeBuffer.Append(&attributeIDs[(const char*)attr->name], 4);
xmlChar* value = xmlNodeGetContent(attr->children);
utf16string textW = CStr8((const char*)value).FromUTF8().utf16();
xmlFree(value);
u32 attrLen = u32(2*(textW.length()+1));
u32 attrLen = u32(xmlStrlen(value)+1);
writeBuffer.Append(&attrLen, 4);
writeBuffer.Append((void*)textW.c_str(), attrLen);
writeBuffer.Append((void*)value, attrLen);
xmlFree(value);
}
// Go back and fill in the child-element offset