fix <invalid UTF-8 string>

* Fix UTF-8 conversion issue on iOS

* Fix visual glitches with TTF font
This commit is contained in:
sfan5 2016-12-11 02:11:01 +01:00 committed by Maksim Gamarnik
parent 23d3335a6b
commit d885c30b2a
2 changed files with 12 additions and 1 deletions

View File

@ -121,7 +121,9 @@ namespace gui
return false;
bool flgmip = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
bool flgcpy = driver->getTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, true);
// Set the texture color format.
switch (pixel_mode)
@ -137,6 +139,7 @@ namespace gui
// Restore our texture creation flags.
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, flgmip);
driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, flgcpy);
return texture ? true : false;
}

View File

@ -87,7 +87,15 @@ std::wstring utf8_to_wide(const std::string &input)
char *outbuf = new char[outbuf_size];
memset(outbuf, 0, outbuf_size);
if (!convert("WCHAR_T", "UTF-8", outbuf, outbuf_size, inbuf, inbuf_size)) {
#ifdef __IOS__
// iOS needs manual caring to support the full character set possible with wchar_t
SANITY_CHECK(sizeof(wchar_t) == 4);
const char *to = "UTF-32LE";
#else
const char *to = "WCHAR_T";
#endif
if (!convert(to, "UTF-8", outbuf, outbuf_size, inbuf, inbuf_size)) {
infostream << "Couldn't convert UTF-8 string 0x" << hex_encode(input)
<< " into wstring" << std::endl;
delete[] inbuf;