1
0
forked from 0ad/0ad
0ad/source/tools/atlas/DatafileIO/Util.cpp
olsner db045c330b # Made Atlas compile on linux
graphics: basic terrain passibility
atlas: lots of changes to make atlas compile under linux
unix/X: more clipboard support - copy from 0AD to other programs
unix/debug: use sys_get_executable_name instead of hard-coded paths
... and lots of other misc. changes

This was SVN commit r4640.
2006-11-12 04:02:36 +00:00

41 lines
852 B
C++

#include "stdafx.h"
#include "Util.h"
#include "Stream/Stream.h"
using namespace DatafileIO;
utf16string DatafileIO::ReadUString(InputStream& stream)
{
uint32_t length;
stream.Read(&length, 4);
utf16string ret;
ret.resize(length);
stream.Read(&ret[0], length*2);
return ret;
}
void DatafileIO::WriteUString(OutputStream& stream, const utf16string& string)
{
uint32_t length = (uint32_t)string.length();
stream.Write(&length, 4);
stream.Write((utf16_t*)&string[0], length*2);
}
#if !OS_WIN
// TODO In reality, these two should be able to de/encode UTF-16 to/from UCS-4
// instead of just treating UTF-16 as UCS-2
std::wstring DatafileIO::utf16tow(const utf16string &str)
{
return std::wstring(str.begin(), str.end());
}
utf16string DatafileIO::wtoutf16(const std::wstring &str)
{
return utf16string(str.begin(), str.end());
}
#endif