fixed NULLbytes for win32 for now by reverting my changes
This commit is contained in:
parent
272ce35cf1
commit
1255f3fd74
|
@ -1,3 +1,4 @@
|
|||
04-apr-2009 - shinydoofy - Reverted UTF8<->UTF32 code changes to fix up the win32 build for now
|
||||
01-apr-2009 - adelikat - Beginning 2.1.1
|
||||
---version 2.1.0 released---
|
||||
29-mar-2009 - adelikat - Win32 - reverted acmlm's /dll folder change
|
||||
|
|
|
@ -585,35 +585,38 @@ namespace UtfConverter
|
|||
size_t widesize = utf8string.length();
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
std::wstring resultstring;
|
||||
resultstring.resize(widesize+1, L'\0');
|
||||
wchar_t* widestringnative = new wchar_t[widesize+1];
|
||||
const UTF8* sourcestart = reinterpret_cast<const UTF8*>(utf8string.c_str());
|
||||
const UTF8* sourceend = sourcestart + widesize;
|
||||
UTF16* targetstart = reinterpret_cast<UTF16*>(&resultstring[0]);
|
||||
UTF16* targetend = targetstart + widesize;
|
||||
UTF16* targetstart = reinterpret_cast<UTF16*>(widestringnative);
|
||||
UTF16* targetend = targetstart + widesize+1;
|
||||
ConversionResult res = ConvertUTF8toUTF16(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] widestringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::wstring resultstring(widestringnative);
|
||||
delete [] widestringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
std::wstring resultstring;
|
||||
resultstring.resize(widesize+1, L'\0');
|
||||
wchar_t* widestringnative = new wchar_t[widesize];
|
||||
const UTF8* sourcestart = reinterpret_cast<const UTF8*>(utf8string.c_str());
|
||||
const UTF8* sourceend = sourcestart + widesize;
|
||||
UTF32* targetstart = reinterpret_cast<UTF32*>(&resultstring[0]);
|
||||
UTF32* targetstart = reinterpret_cast<UTF32*>(widestringnative);
|
||||
UTF32* targetend = targetstart + widesize;
|
||||
ConversionResult res = ConvertUTF8toUTF32(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] widestringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
resultstring = resultstring.substr(0, 23);
|
||||
std::wstring resultstring(widestringnative);
|
||||
delete [] widestringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else
|
||||
|
@ -630,35 +633,39 @@ namespace UtfConverter
|
|||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
size_t utf8size = 3 * widesize + 1;
|
||||
std::string resultstring;
|
||||
resultstring.resize(utf8size, '\0');
|
||||
char* utf8stringnative = new char[utf8size];
|
||||
const UTF16* sourcestart = reinterpret_cast<const UTF16*>(widestring.c_str());
|
||||
const UTF16* sourceend = sourcestart + widesize;
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(&resultstring[0]);
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(utf8stringnative);
|
||||
UTF8* targetend = targetstart + utf8size;
|
||||
ConversionResult res = ConvertUTF16toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] utf8stringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::string resultstring(utf8stringnative);
|
||||
delete [] utf8stringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
size_t utf8size = 4 * widesize + 1;
|
||||
std::string resultstring;
|
||||
resultstring.resize(utf8size, '\0');
|
||||
char* utf8stringnative = new char[utf8size];
|
||||
const UTF32* sourcestart = reinterpret_cast<const UTF32*>(widestring.c_str());
|
||||
const UTF32* sourceend = sourcestart + widesize;
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(&resultstring[0]);
|
||||
UTF8* targetstart = reinterpret_cast<UTF8*>(utf8stringnative);
|
||||
UTF8* targetend = targetstart + utf8size;
|
||||
ConversionResult res = ConvertUTF32toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion);
|
||||
if (res != conversionOK)
|
||||
{
|
||||
delete [] utf8stringnative;
|
||||
throw std::exception();
|
||||
}
|
||||
*targetstart = 0;
|
||||
std::string resultstring(utf8stringnative);
|
||||
delete [] utf8stringnative;
|
||||
return resultstring;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue