Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3097 from Karlson2k/charsetconverter_rework_01

CharsetConverter rework - part 1
  • Loading branch information...
commit ecce0015c29bf74758af2a47524a9e09c3cdb3d4 2 parents 1f83206 + 4af1fcd
@MartijnKaijser MartijnKaijser authored
View
6 configure.in
@@ -916,6 +916,12 @@ if test "x$have_builtin_sync_val_compare_and_swap" = "xyes"; then
[Define to 1 if your compiler supports the __sync_val_compare_and_swap() intrinsic.])
fi
+# Check for u16string/u32string declarations
+AC_LANG_PUSH([C++])
+AC_CHECK_TYPES([std::u16string, std::u32string], [], [], [[#include <string>]])
+AC_CHECK_TYPES([char16_t, char32_t])
+AC_LANG_POP([C++])
+
# Add top source directory for all builds so we can use config.h
INCLUDES="-I\$(abs_top_srcdir) $INCLUDES"
View
1  project/VS2010Express/XBMC.vcxproj
@@ -1210,6 +1210,7 @@
<ClInclude Include="..\..\xbmc\utils\LegacyPathTranslation.h" />
<ClInclude Include="..\..\xbmc\utils\RssManager.h" />
<ClInclude Include="..\..\xbmc\utils\StringValidation.h" />
+ <ClInclude Include="..\..\xbmc\utils\uXstrings.h" />
<ClInclude Include="..\..\xbmc\utils\Vector.h" />
<ClInclude Include="..\..\xbmc\video\FFmpegVideoDecoder.h" />
<ClInclude Include="..\..\xbmc\interfaces\python\swig.h" />
View
3  project/VS2010Express/XBMC.vcxproj.filters
@@ -6034,6 +6034,9 @@
<ClInclude Include="..\..\xbmc\utils\StringValidation.h">
<Filter>utils</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\utils\uXstrings.h">
+ <Filter>utils</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc">
View
2  xbmc/NfoFile.h
@@ -65,7 +65,7 @@ class CNfoFile
if (encoding.IsEmpty())
g_charsetConverter.unknownToUTF8(strUtf8);
else
- g_charsetConverter.stringCharsetToUtf8(encoding, strDoc, strUtf8);
+ g_charsetConverter.ToUtf8(encoding, strDoc, strUtf8);
doc.Clear();
doc.Parse(strUtf8.c_str(),0,TIXML_ENCODING_UTF8);
View
2  xbmc/cores/DllLoader/Win32DllLoader.cpp
@@ -157,7 +157,7 @@ bool Win32DllLoader::Load()
CStdString strFileName = GetFileName();
CStdStringW strDllW;
- g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strFileName), strDllW);
+ g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strFileName), strDllW, false, false, false);
m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (!m_dllHandle)
{
View
2  xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitleStream.cpp
@@ -61,7 +61,7 @@ bool CDVDSubtitleStream::Open(const string& strFile)
{
buffer[size_read] = buffer[size_read + 1] = '\0';
CStdStringW temp;
- g_charsetConverter.utf16LEtoW(CStdString16((uint16_t*)buffer),temp);
+ g_charsetConverter.utf16LEtoW(std::u16string((char16_t*)buffer),temp);
wstringstream << temp;
}
delete pInputStream;
View
2  xbmc/filesystem/iso9660.cpp
@@ -701,7 +701,7 @@ bool iso9660::FindClose( HANDLE szLocalFolder )
string iso9660::GetThinText(BYTE* strTxt, int iLen )
{
// convert from "fat" text (UTF-16BE) to "thin" text (UTF-8)
- CStdString16 strTxtUnicode((uint16_t*)strTxt, iLen / 2);
+ std::u16string strTxtUnicode((char16_t*)strTxt, iLen / 2);
CStdString utf8String;
g_charsetConverter.utf16BEtoUTF8(strTxtUnicode, utf8String);
View
2  xbmc/guilib/LocalizeStrings.cpp
@@ -45,7 +45,7 @@ CStdString CLocalizeStrings::ToUTF8(const CStdString& strEncoding, const CStdStr
return str;
CStdString ret;
- g_charsetConverter.stringCharsetToUtf8(strEncoding, str, ret);
+ g_charsetConverter.ToUtf8(strEncoding, str, ret);
return ret;
}
View
2  xbmc/music/karaoke/karaokelyricstextkar.cpp
@@ -603,7 +603,7 @@ CStdString CKaraokeLyricsTextKAR::convertText( const char * data )
if ( g_charsetConverter.isValidUtf8(data) || CSettings::Get().GetString("karaoke.charset") == "DEFAULT" )
strUTF8 = data;
else
- g_charsetConverter.stringCharsetToUtf8( CSettings::Get().GetString("karaoke.charset"), data, strUTF8 );
+ g_charsetConverter.ToUtf8( CSettings::Get().GetString("karaoke.charset"), data, strUTF8 );
if ( strUTF8.size() == 0 )
strUTF8 = " ";
View
2  xbmc/pictures/PictureInfoTag.cpp
@@ -328,7 +328,7 @@ const CStdString CPictureInfoTag::GetInfo(int info) const
// Ascii, Unicode (UCS2), JIS (X208-1990), Unknown (application specific)
if (m_exifInfo.CommentsCharset == EXIF_COMMENT_CHARSET_UNICODE)
{
- g_charsetConverter.ucs2ToUTF8(CStdString16((uint16_t*)m_exifInfo.Comments), value);
+ g_charsetConverter.ucs2ToUTF8(std::u16string((char16_t*)m_exifInfo.Comments), value);
}
else
{
View
4 xbmc/playlists/SmartPlayList.cpp
@@ -211,7 +211,7 @@ bool CSmartPlaylistRule::Load(const TiXmlNode *node, const std::string &encoding
if (encoding.empty()) // utf8
utf8Parameter = parameter->ValueStr();
else
- g_charsetConverter.stringCharsetToUtf8(encoding, parameter->ValueStr(), utf8Parameter);
+ g_charsetConverter.ToUtf8(encoding, parameter->ValueStr(), utf8Parameter);
if (!utf8Parameter.empty())
m_parameter.push_back(utf8Parameter);
@@ -228,7 +228,7 @@ bool CSmartPlaylistRule::Load(const TiXmlNode *node, const std::string &encoding
if (encoding.empty()) // utf8
utf8Parameter = value->ValueStr();
else
- g_charsetConverter.stringCharsetToUtf8(encoding, value->ValueStr(), utf8Parameter);
+ g_charsetConverter.ToUtf8(encoding, value->ValueStr(), utf8Parameter);
if (!utf8Parameter.empty())
m_parameter.push_back(utf8Parameter);
View
372 xbmc/utils/CharsetConverter.cpp
@@ -20,6 +20,7 @@
#include "CharsetConverter.h"
#include "Util.h"
+#include "utils/StringUtils.h"
#include <fribidi/fribidi.h>
#include "LangInfo.h"
#include "guilib/LocalizeStrings.h"
@@ -55,11 +56,9 @@
#endif
-static iconv_t m_iconvStringCharsetToFontCharset = (iconv_t)-1;
static iconv_t m_iconvSubtitleCharsetToW = (iconv_t)-1;
static iconv_t m_iconvUtf8ToStringCharset = (iconv_t)-1;
static iconv_t m_iconvStringCharsetToUtf8 = (iconv_t)-1;
-static iconv_t m_iconvUcs2CharsetToStringCharset = (iconv_t)-1;
static iconv_t m_iconvUtf32ToStringCharset = (iconv_t)-1;
static iconv_t m_iconvWtoUtf8 = (iconv_t)-1;
static iconv_t m_iconvUtf16LEtoW = (iconv_t)-1;
@@ -137,13 +136,15 @@ static struct SCharsetMapping
};
-#define UTF8_DEST_MULTIPLIER 6
+/* single symbol sizes in chars */
+const int CCharsetConverter::m_Utf8CharMinSize = 1;
+const int CCharsetConverter::m_Utf8CharMaxSize = 6;
#define ICONV_PREPARE(iconv) iconv=(iconv_t)-1
#define ICONV_SAFE_CLOSE(iconv) if (iconv!=(iconv_t)-1) { iconv_close(iconv); iconv=(iconv_t)-1; }
-size_t iconv_const (void* cd, const char** inbuf, size_t *inbytesleft,
- char* * outbuf, size_t *outbytesleft)
+size_t iconv_const (void* cd, const char** inbuf, size_t* inbytesleft,
+ char** outbuf, size_t* outbytesleft)
{
struct iconv_param_adapter {
iconv_param_adapter(const char**p) : p(p) {}
@@ -163,8 +164,10 @@ size_t iconv_const (void* cd, const char** inbuf, size_t *inbytesleft,
}
template<class INPUT,class OUTPUT>
-static bool convert_checked(iconv_t& type, int multiplier, const CStdString& strFromCharset, const CStdString& strToCharset, const INPUT& strSource, OUTPUT& strDest)
+static bool convert(iconv_t& type, int multiplier, const std::string& strFromCharset, const std::string& strToCharset, const INPUT& strSource, OUTPUT& strDest, bool failOnInvalidChar = false)
{
+ strDest.clear();
+
if (type == (iconv_t)-1)
{
type = iconv_open(strToCharset.c_str(), strFromCharset.c_str());
@@ -176,31 +179,34 @@ static bool convert_checked(iconv_t& type, int multiplier, const CStdString& str
}
}
- if (strSource.IsEmpty())
- {
- strDest.clear(); //empty strings are easy
- return true;
- }
+ if (strSource.empty())
+ return true; //empty strings are easy
//input buffer for iconv() is the buffer from strSource
- size_t inBufSize = (strSource.length() + 1) * sizeof(strSource[0]);
+ size_t inBufSize = (strSource.length() + 1) * sizeof(typename INPUT::value_type);
const char* inBuf = (const char*)strSource.c_str();
//allocate output buffer for iconv()
- size_t outBufSize = (strSource.length() + 1) * multiplier;
+ size_t outBufSize = (strSource.length() + 1) * sizeof(typename OUTPUT::value_type) * multiplier;
char* outBuf = (char*)malloc(outBufSize);
+ if (outBuf == NULL)
+ {
+ CLog::Log(LOGSEVERE, "%s: malloc failed", __FUNCTION__);
+ return false;
+ }
size_t inBytesAvail = inBufSize; //how many bytes iconv() can read
size_t outBytesAvail = outBufSize; //how many bytes iconv() can write
const char* inBufStart = inBuf; //where in our input buffer iconv() should start reading
char* outBufStart = outBuf; //where in out output buffer iconv() should start writing
+ size_t returnV;
while(1)
{
//iconv() will update inBufStart, inBytesAvail, outBufStart and outBytesAvail
- size_t returnV = iconv_const(type, &inBufStart, &inBytesAvail, &outBufStart, &outBytesAvail);
+ returnV = iconv_const(type, &inBufStart, &inBytesAvail, &outBufStart, &outBytesAvail);
- if ((returnV == (size_t)-1) && (errno != EINVAL))
+ if (returnV == (size_t)-1)
{
if (errno == E2BIG) //output buffer is not big enough
{
@@ -212,10 +218,9 @@ static bool convert_checked(iconv_t& type, int multiplier, const CStdString& str
char* newBuf = (char*)realloc(outBuf, outBufSize);
if (!newBuf)
{
- CLog::Log(LOGERROR, "%s realloc failed with buffer=%p size=%zu errno=%d(%s)",
- __FUNCTION__, outBuf, outBufSize, errno, strerror(errno));
- free(outBuf);
- return false;
+ CLog::Log(LOGSEVERE, "%s realloc failed with errno=%d(%s)",
+ __FUNCTION__, errno, strerror(errno));
+ break;
}
outBuf = newBuf;
@@ -224,79 +229,96 @@ static bool convert_checked(iconv_t& type, int multiplier, const CStdString& str
outBytesAvail = outBufSize - bytesConverted;
//continue in the loop and convert the rest
+ continue;
}
else if (errno == EILSEQ) //An invalid multibyte sequence has been encountered in the input
{
+ if (failOnInvalidChar)
+ break;
+
//skip invalid byte
inBufStart++;
inBytesAvail--;
-
//continue in the loop and convert the rest
+ continue;
+ }
+ else if (errno == EINVAL) /* Invalid sequence at the end of input buffer */
+ {
+ if (!failOnInvalidChar)
+ returnV = 0; /* reset error status to use converted part */
+
+ break;
}
else //iconv() had some other error
{
CLog::Log(LOGERROR, "%s iconv() failed from %s to %s, errno=%d(%s)",
__FUNCTION__, strFromCharset.c_str(), strToCharset.c_str(), errno, strerror(errno));
- free(outBuf);
- return false;
}
}
- else
- {
- //complete the conversion, otherwise the current data will prefix the data on the next call
- returnV = iconv_const(type, NULL, NULL, &outBufStart, &outBytesAvail);
- if (returnV == (size_t)-1)
- CLog::Log(LOGERROR, "%s failed cleanup errno=%d(%s)", __FUNCTION__, errno, strerror(errno));
-
- //we're done
- break;
- }
+ break;
}
- size_t bytesWritten = outBufSize - outBytesAvail;
- char* dest = (char*)strDest.GetBuffer(bytesWritten);
+ //complete the conversion (reset buffers), otherwise the current data will prefix the data on the next call
+ if (iconv_const(type, NULL, NULL, &outBufStart, &outBytesAvail) == (size_t)-1)
+ CLog::Log(LOGERROR, "%s failed cleanup errno=%d(%s)", __FUNCTION__, errno, strerror(errno));
- //copy the output from iconv() into the CStdString
- memcpy(dest, outBuf, bytesWritten);
+ if (returnV == (size_t)-1)
+ {
+ free(outBuf);
+ return false;
+ }
+ //we're done
+
+ const typename OUTPUT::size_type sizeInChars = (typename OUTPUT::size_type) (outBufSize - outBytesAvail) / sizeof(typename OUTPUT::value_type);
+ typename OUTPUT::const_pointer strPtr = (typename OUTPUT::const_pointer) outBuf;
+ /* Make sure that all buffer is assigned and string is stopped at end of buffer */
+ if (strPtr[sizeInChars-1] == 0)
+ strDest.assign(strPtr, sizeInChars-1);
+ else
+ strDest.assign(strPtr, sizeInChars);
- strDest.ReleaseBuffer();
-
free(outBuf);
return true;
}
-template<class INPUT,class OUTPUT>
-static void convert(iconv_t& type, int multiplier, const CStdString& strFromCharset, const CStdString& strToCharset, const INPUT& strSource, OUTPUT& strDest)
-{
- if(!convert_checked(type, multiplier, strFromCharset, strToCharset, strSource, strDest))
- strDest = strSource;
-}
-
using namespace std;
-static void logicalToVisualBiDi(const CStdStringA& strSource, CStdStringA& strDest, FriBidiCharSet fribidiCharset, FriBidiCharType base = FRIBIDI_TYPE_LTR, bool* bWasFlipped =NULL)
+static bool logicalToVisualBiDi(const std::string& stringSrc, std::string& stringDst, FriBidiCharSet fribidiCharset, FriBidiCharType base = FRIBIDI_TYPE_LTR, bool* bWasFlipped =NULL)
{
- // libfribidi is not threadsafe, so make sure we make it so
- CSingleLock lock(m_critSection);
-
- vector<CStdString> lines;
- CUtil::Tokenize(strSource, lines, "\n");
- CStdString resultString;
+ stringDst.clear();
+ vector<std::string> lines = StringUtils::Split(stringSrc, "\n");
if (bWasFlipped)
*bWasFlipped = false;
- for (unsigned int i = 0; i < lines.size(); i++)
+ // libfribidi is not threadsafe, so make sure we make it so
+ CSingleLock lock(m_critSection);
+
+ const size_t numLines = lines.size();
+ for (size_t i = 0; i < numLines; i++)
{
int sourceLen = lines[i].length();
// Convert from the selected charset to Unicode
FriBidiChar* logical = (FriBidiChar*) malloc((sourceLen + 1) * sizeof(FriBidiChar));
+ if (logical == NULL)
+ {
+ CLog::Log(LOGSEVERE, "%s: can't allocate memory", __FUNCTION__);
+ return false;
+ }
int len = fribidi_charset_to_unicode(fribidiCharset, (char*) lines[i].c_str(), sourceLen, logical);
FriBidiChar* visual = (FriBidiChar*) malloc((len + 1) * sizeof(FriBidiChar));
FriBidiLevel* levels = (FriBidiLevel*) malloc((len + 1) * sizeof(FriBidiLevel));
+ if (levels == NULL || visual == NULL)
+ {
+ free(logical);
+ free(visual);
+ free(levels);
+ CLog::Log(LOGSEVERE, "%s: can't allocate memory", __FUNCTION__);
+ return false;
+ }
if (fribidi_log2vis(logical, len, &base, visual, NULL, NULL, levels))
{
@@ -306,14 +328,13 @@ static void logicalToVisualBiDi(const CStdStringA& strSource, CStdStringA& strDe
// Apperently a string can get longer during this transformation
// so make sure we allocate the maximum possible character utf8
// can generate atleast, should cover all bases
- char *result = strDest.GetBuffer(len*4);
+ char* result = new char[len*4];
// Convert back from Unicode to the charset
int len2 = fribidi_unicode_to_charset(fribidiCharset, visual, len, result);
- ASSERT(len2 <= len*4);
- strDest.ReleaseBuffer();
-
- resultString += strDest;
+ assert(len2 <= len*4);
+ stringDst += result;
+ delete[] result;
// Check whether the string was flipped if one of the embedding levels is greater than 0
if (bWasFlipped && !*bWasFlipped)
@@ -334,19 +355,19 @@ static void logicalToVisualBiDi(const CStdStringA& strSource, CStdStringA& strDe
free(levels);
}
- strDest = resultString;
+ return true;
}
CCharsetConverter::CCharsetConverter()
{
}
-void CCharsetConverter::OnSettingChanged(const CSetting *setting)
+void CCharsetConverter::OnSettingChanged(const CSetting* setting)
{
if (setting == NULL)
return;
- const std::string &settingId = setting->GetId();
+ const std::string& settingId = setting->GetId();
// TODO: does this make any sense at all for subtitles and karaoke?
if (settingId == "subtitles.charset" ||
settingId == "karaoke.charset" ||
@@ -358,42 +379,42 @@ void CCharsetConverter::clear()
{
}
-vector<CStdString> CCharsetConverter::getCharsetLabels()
+std::vector<std::string> CCharsetConverter::getCharsetLabels()
{
- vector<CStdString> lab;
- for(SCharsetMapping * c = g_charsets; c->charset; c++)
+ vector<std::string> lab;
+ for(SCharsetMapping* c = g_charsets; c->charset; c++)
lab.push_back(c->caption);
return lab;
}
-CStdString CCharsetConverter::getCharsetLabelByName(const CStdString& charsetName)
+std::string CCharsetConverter::getCharsetLabelByName(const std::string& charsetName)
{
- for(SCharsetMapping * c = g_charsets; c->charset; c++)
+ for(SCharsetMapping* c = g_charsets; c->charset; c++)
{
- if (charsetName.Equals(c->charset))
+ if (StringUtils::EqualsNoCase(charsetName,c->charset))
return c->caption;
}
return "";
}
-CStdString CCharsetConverter::getCharsetNameByLabel(const CStdString& charsetLabel)
+std::string CCharsetConverter::getCharsetNameByLabel(const std::string& charsetLabel)
{
- for(SCharsetMapping *c = g_charsets; c->charset; c++)
+ for(SCharsetMapping* c = g_charsets; c->charset; c++)
{
- if (charsetLabel.Equals(c->caption))
+ if (StringUtils::EqualsNoCase(charsetLabel, c->caption))
return c->charset;
}
return "";
}
-bool CCharsetConverter::isBidiCharset(const CStdString& charset)
+bool CCharsetConverter::isBidiCharset(const std::string& charset)
{
- for(SFribidMapping *c = g_fribidi; c->charset; c++)
+ for(SFribidMapping* c = g_fribidi; c->charset; c++)
{
- if (charset.Equals(c->charset))
+ if (StringUtils::EqualsNoCase(charset, c->charset))
return true;
}
return false;
@@ -403,10 +424,8 @@ void CCharsetConverter::reset(void)
{
CSingleLock lock(m_critSection);
- ICONV_SAFE_CLOSE(m_iconvStringCharsetToFontCharset);
ICONV_SAFE_CLOSE(m_iconvUtf8ToStringCharset);
ICONV_SAFE_CLOSE(m_iconvStringCharsetToUtf8);
- ICONV_SAFE_CLOSE(m_iconvUcs2CharsetToStringCharset);
ICONV_SAFE_CLOSE(m_iconvSubtitleCharsetToW);
ICONV_SAFE_CLOSE(m_iconvWtoUtf8);
ICONV_SAFE_CLOSE(m_iconvUtf16BEtoUtf8);
@@ -418,237 +437,188 @@ void CCharsetConverter::reset(void)
m_stringFribidiCharset = FRIBIDI_NOTFOUND;
- CStdString strCharset=g_langInfo.GetGuiCharSet();
- for(SFribidMapping *c = g_fribidi; c->charset; c++)
+ std::string strCharset=g_langInfo.GetGuiCharSet();
+ for(SFribidMapping* c = g_fribidi; c->charset; c++)
{
- if (strCharset.Equals(c->charset))
+ if (StringUtils::EqualsNoCase(strCharset, c->charset))
+ {
m_stringFribidiCharset = c->name;
+ break;
+ }
}
}
// The bVisualBiDiFlip forces a flip of characters for hebrew/arabic languages, only set to false if the flipping
// of the string is already made or the string is not displayed in the GUI
-void CCharsetConverter::utf8ToW(const CStdStringA& utf8String, CStdStringW &wString, bool bVisualBiDiFlip/*=true*/, bool forceLTRReadingOrder /*=false*/, bool* bWasFlipped/*=NULL*/)
+bool CCharsetConverter::utf8ToW(const std::string& utf8StringSrc, std::wstring& wStringDst, bool bVisualBiDiFlip /*= true*/,
+ bool forceLTRReadingOrder /*= false*/, bool failOnBadChar /*= false*/, bool* bWasFlipped /*= NULL*/)
{
// Try to flip hebrew/arabic characters, if any
if (bVisualBiDiFlip)
{
- CStdStringA strFlipped;
+ std::string strFlipped;
FriBidiCharType charset = forceLTRReadingOrder ? FRIBIDI_TYPE_LTR : FRIBIDI_TYPE_PDF;
- logicalToVisualBiDi(utf8String, strFlipped, FRIBIDI_UTF8, charset, bWasFlipped);
+ logicalToVisualBiDi(utf8StringSrc, strFlipped, FRIBIDI_UTF8, charset, bWasFlipped);
CSingleLock lock(m_critSection);
- convert(m_iconvUtf8toW,sizeof(wchar_t),UTF8_SOURCE,WCHAR_CHARSET,strFlipped,wString);
+ return convert(m_iconvUtf8toW,1,UTF8_SOURCE,WCHAR_CHARSET,strFlipped,wStringDst, failOnBadChar);
}
else
{
CSingleLock lock(m_critSection);
- convert(m_iconvUtf8toW,sizeof(wchar_t),UTF8_SOURCE,WCHAR_CHARSET,utf8String,wString);
+ return convert(m_iconvUtf8toW,1,UTF8_SOURCE,WCHAR_CHARSET,utf8StringSrc,wStringDst, failOnBadChar);
}
}
-void CCharsetConverter::subtitleCharsetToW(const CStdStringA& strSource, CStdStringW& strDest)
+bool CCharsetConverter::subtitleCharsetToW(const std::string& stringSrc, std::wstring& wStringDst)
{
// No need to flip hebrew/arabic as mplayer does the flipping
CSingleLock lock(m_critSection);
- convert(m_iconvSubtitleCharsetToW,sizeof(wchar_t),g_langInfo.GetSubtitleCharSet(),WCHAR_CHARSET,strSource,strDest);
+ return convert(m_iconvSubtitleCharsetToW,1,g_langInfo.GetSubtitleCharSet(),WCHAR_CHARSET,stringSrc,wStringDst);
}
-void CCharsetConverter::fromW(const CStdStringW& strSource,
- CStdStringA& strDest, const CStdString& enc)
+bool CCharsetConverter::fromW(const std::wstring& wStringSrc,
+ std::string& stringDst, const std::string& enc)
{
iconv_t iconvString;
ICONV_PREPARE(iconvString);
- convert(iconvString,4,WCHAR_CHARSET,enc,strSource,strDest);
+ const bool result = convert(iconvString,m_Utf8CharMaxSize,WCHAR_CHARSET,enc,wStringSrc,stringDst);
iconv_close(iconvString);
+ return result;
}
-void CCharsetConverter::toW(const CStdStringA& strSource,
- CStdStringW& strDest, const CStdString& enc)
+bool CCharsetConverter::toW(const std::string& stringSrc,
+ std::wstring& wStringDst, const std::string& enc)
{
iconv_t iconvString;
ICONV_PREPARE(iconvString);
- convert(iconvString,sizeof(wchar_t),enc,WCHAR_CHARSET,strSource,strDest);
+ const bool result = convert(iconvString,1,enc,WCHAR_CHARSET,stringSrc,wStringDst);
iconv_close(iconvString);
+ return result;
}
-void CCharsetConverter::utf8ToStringCharset(const CStdStringA& strSource, CStdStringA& strDest)
+bool CCharsetConverter::utf8ToStringCharset(const std::string& utf8StringSrc, std::string& stringDst)
{
CSingleLock lock(m_critSection);
- convert(m_iconvUtf8ToStringCharset,1,UTF8_SOURCE,g_langInfo.GetGuiCharSet(),strSource,strDest);
+ return convert(m_iconvUtf8ToStringCharset,1,UTF8_SOURCE,g_langInfo.GetGuiCharSet(),utf8StringSrc,stringDst);
}
-void CCharsetConverter::utf8ToStringCharset(CStdStringA& strSourceDest)
+bool CCharsetConverter::utf8ToStringCharset(std::string& stringSrcDst)
{
- CStdString strDest;
- utf8ToStringCharset(strSourceDest, strDest);
- strSourceDest=strDest;
+ std::string strSrc(stringSrcDst);
+ return utf8ToStringCharset(strSrc, stringSrcDst);
}
-void CCharsetConverter::stringCharsetToUtf8(const CStdStringA& strSourceCharset, const CStdStringA& strSource, CStdStringA& strDest)
+bool CCharsetConverter::ToUtf8(const std::string& strSourceCharset, const std::string& stringSrc, std::string& utf8StringDst)
{
+ if (strSourceCharset == "UTF-8")
+ { // simple case - no conversion necessary
+ utf8StringDst = stringSrc;
+ return true;
+ }
iconv_t iconvString;
ICONV_PREPARE(iconvString);
- convert(iconvString,UTF8_DEST_MULTIPLIER,strSourceCharset,"UTF-8",strSource,strDest);
+ const bool result = convert(iconvString,m_Utf8CharMaxSize,strSourceCharset,"UTF-8",stringSrc,utf8StringDst);
iconv_close(iconvString);
+ return result;
}
-void CCharsetConverter::utf8To(const CStdStringA& strDestCharset, const CStdStringA& strSource, CStdStringA& strDest)
+bool CCharsetConverter::utf8To(const std::string& strDestCharset, const std::string& utf8StringSrc, std::string& stringDst)
{
if (strDestCharset == "UTF-8")
{ // simple case - no conversion necessary
- strDest = strSource;
- return;
+ stringDst = utf8StringSrc;
+ return true;
}
iconv_t iconvString;
ICONV_PREPARE(iconvString);
- convert(iconvString,UTF8_DEST_MULTIPLIER,UTF8_SOURCE,strDestCharset,strSource,strDest);
+ const bool result = convert(iconvString,1,UTF8_SOURCE,strDestCharset,utf8StringSrc,stringDst);
iconv_close(iconvString);
+ return result;
}
-void CCharsetConverter::utf8To(const CStdStringA& strDestCharset, const CStdStringA& strSource, CStdString16& strDest)
+bool CCharsetConverter::utf8To(const std::string& strDestCharset, const std::string& utf8StringSrc, std::u16string& utf16StringDst)
{
iconv_t iconvString;
ICONV_PREPARE(iconvString);
- if(!convert_checked(iconvString,UTF8_DEST_MULTIPLIER,UTF8_SOURCE,strDestCharset,strSource,strDest))
- strDest.clear();
+ const bool result = convert(iconvString,1,UTF8_SOURCE,strDestCharset,utf8StringSrc,utf16StringDst);
iconv_close(iconvString);
+ return result;
}
-void CCharsetConverter::utf8To(const CStdStringA& strDestCharset, const CStdStringA& strSource, CStdString32& strDest)
+bool CCharsetConverter::utf8To(const std::string& strDestCharset, const std::string& utf8StringSrc, std::u32string& utf32StringDst)
{
iconv_t iconvString;
ICONV_PREPARE(iconvString);
- if(!convert_checked(iconvString,UTF8_DEST_MULTIPLIER,UTF8_SOURCE,strDestCharset,strSource,strDest))
- strDest.clear();
+ const bool result = convert(iconvString,1,UTF8_SOURCE,strDestCharset,utf8StringSrc,utf32StringDst);
iconv_close(iconvString);
+ return result;
}
-void CCharsetConverter::unknownToUTF8(CStdStringA &sourceAndDest)
+bool CCharsetConverter::unknownToUTF8(std::string& stringSrcDst)
{
- CStdString source = sourceAndDest;
- unknownToUTF8(source, sourceAndDest);
+ std::string source(stringSrcDst);
+ return unknownToUTF8(source, stringSrcDst);
}
-void CCharsetConverter::unknownToUTF8(const CStdStringA &source, CStdStringA &dest)
+bool CCharsetConverter::unknownToUTF8(const std::string& stringSrc, std::string& utf8StringDst, bool failOnBadChar /*= false*/)
{
// checks whether it's utf8 already, and if not converts using the sourceCharset if given, else the string charset
- if (isValidUtf8(source))
- dest = source;
- else
+ if (isValidUtf8(stringSrc))
{
- CSingleLock lock(m_critSection);
- convert(m_iconvStringCharsetToUtf8, UTF8_DEST_MULTIPLIER, g_langInfo.GetGuiCharSet(), "UTF-8", source, dest);
+ utf8StringDst = stringSrc;
+ return true;
}
-}
-
-void CCharsetConverter::wToUTF8(const CStdStringW& strSource, CStdStringA &strDest)
-{
CSingleLock lock(m_critSection);
- convert(m_iconvWtoUtf8,UTF8_DEST_MULTIPLIER,WCHAR_CHARSET,"UTF-8",strSource,strDest);
+ return convert(m_iconvStringCharsetToUtf8, m_Utf8CharMaxSize, g_langInfo.GetGuiCharSet(), "UTF-8", stringSrc, utf8StringDst, failOnBadChar);
}
-void CCharsetConverter::utf16BEtoUTF8(const CStdString16& strSource, CStdStringA &strDest)
+bool CCharsetConverter::wToUTF8(const std::wstring& wStringSrc, std::string& utf8StringDst, bool failOnBadChar /*= false*/)
{
CSingleLock lock(m_critSection);
- if(!convert_checked(m_iconvUtf16BEtoUtf8,UTF8_DEST_MULTIPLIER,"UTF-16BE","UTF-8",strSource,strDest))
- strDest.clear();
+ return convert(m_iconvWtoUtf8,m_Utf8CharMaxSize,WCHAR_CHARSET,"UTF-8",wStringSrc,utf8StringDst, failOnBadChar);
}
-void CCharsetConverter::utf16LEtoUTF8(const CStdString16& strSource,
- CStdStringA &strDest)
+bool CCharsetConverter::utf16BEtoUTF8(const std::u16string& utf16StringSrc, std::string& utf8StringDst)
{
CSingleLock lock(m_critSection);
- if(!convert_checked(m_iconvUtf16LEtoUtf8,UTF8_DEST_MULTIPLIER,"UTF-16LE","UTF-8",strSource,strDest))
- strDest.clear();
+ return convert(m_iconvUtf16BEtoUtf8,m_Utf8CharMaxSize,"UTF-16BE","UTF-8",utf16StringSrc,utf8StringDst);
}
-void CCharsetConverter::ucs2ToUTF8(const CStdString16& strSource, CStdStringA& strDest)
+bool CCharsetConverter::utf16LEtoUTF8(const std::u16string& utf16StringSrc,
+ std::string& utf8StringDst)
{
CSingleLock lock(m_critSection);
- if(!convert_checked(m_iconvUcs2CharsetToUtf8,UTF8_DEST_MULTIPLIER,"UCS-2LE","UTF-8",strSource,strDest))
- strDest.clear();
+ return convert(m_iconvUtf16LEtoUtf8,m_Utf8CharMaxSize,"UTF-16LE","UTF-8",utf16StringSrc,utf8StringDst);
}
-void CCharsetConverter::utf16LEtoW(const CStdString16& strSource, CStdStringW &strDest)
+bool CCharsetConverter::ucs2ToUTF8(const std::u16string& ucs2StringSrc, std::string& utf8StringDst)
{
CSingleLock lock(m_critSection);
- if(!convert_checked(m_iconvUtf16LEtoW,sizeof(wchar_t),"UTF-16LE",WCHAR_CHARSET,strSource,strDest))
- strDest.clear();
+ return convert(m_iconvUcs2CharsetToUtf8,m_Utf8CharMaxSize,"UCS-2LE","UTF-8",ucs2StringSrc,utf8StringDst);
}
-void CCharsetConverter::ucs2CharsetToStringCharset(const CStdStringW& strSource, CStdStringA& strDest, bool swap)
+bool CCharsetConverter::utf16LEtoW(const std::u16string& utf16String, std::wstring& wString)
{
- CStdStringW strCopy = strSource;
- if (swap)
- {
- char* s = (char*) strCopy.c_str();
-
- while (*s || *(s + 1))
- {
- char c = *s;
- *s = *(s + 1);
- *(s + 1) = c;
-
- s++;
- s++;
- }
- }
CSingleLock lock(m_critSection);
- convert(m_iconvUcs2CharsetToStringCharset,4,"UTF-16LE",
- g_langInfo.GetGuiCharSet(),strCopy,strDest);
+ return convert(m_iconvUtf16LEtoW,1,"UTF-16LE",WCHAR_CHARSET,utf16String,wString);
}
-void CCharsetConverter::utf32ToStringCharset(const unsigned long* strSource, CStdStringA& strDest)
+bool CCharsetConverter::utf32ToStringCharset(const std::u32string& utf32StringSrc, std::string& stringDst)
{
CSingleLock lock(m_critSection);
-
- if (m_iconvUtf32ToStringCharset == (iconv_t) - 1)
- {
- CStdString strCharset=g_langInfo.GetGuiCharSet();
- m_iconvUtf32ToStringCharset = iconv_open(strCharset.c_str(), "UTF-32LE");
- }
-
- if (m_iconvUtf32ToStringCharset != (iconv_t) - 1)
- {
- const unsigned long* ptr=strSource;
- while (*ptr) ptr++;
- const char* src = (const char*) strSource;
- size_t inBytes = (ptr-strSource+1)*4;
-
- char *dst = strDest.GetBuffer(inBytes);
- size_t outBytes = inBytes;
-
- if (iconv_const(m_iconvUtf32ToStringCharset, &src, &inBytes, &dst, &outBytes) == (size_t)-1)
- {
- CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
- strDest.ReleaseBuffer();
- strDest = (const char *)strSource;
- return;
- }
-
- if (iconv(m_iconvUtf32ToStringCharset, NULL, NULL, &dst, &outBytes) == (size_t)-1)
- {
- CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
- strDest.ReleaseBuffer();
- strDest = (const char *)strSource;
- return;
- }
-
- strDest.ReleaseBuffer();
- }
+ return convert(m_iconvUtf32ToStringCharset, 1, g_langInfo.GetGuiCharSet().c_str(), "UTF-32", utf32StringSrc, stringDst);
}
-void CCharsetConverter::utf8ToSystem(CStdStringA& strSourceDest)
+bool CCharsetConverter::utf8ToSystem(std::string& stringSrcDst, bool failOnBadChar /*= false*/)
{
- CStdString strDest;
- g_charsetConverter.utf8To("", strSourceDest, strDest);
- strSourceDest = strDest;
+ std::string strSrc(stringSrcDst);
+ return utf8To("", strSrc, stringSrcDst);
}
// Taken from RFC2640
-bool CCharsetConverter::isValidUtf8(const char *buf, unsigned int len)
+bool CCharsetConverter::isValidUtf8(const char* buf, unsigned int len)
{
- const unsigned char *endbuf = (unsigned char*)buf + len;
+ const unsigned char* endbuf = (unsigned char*)buf + len;
unsigned char byte2mask=0x00, c;
int trailing=0; // trailing (continuation) bytes to follow
@@ -706,19 +676,19 @@ bool CCharsetConverter::isValidUtf8(const char *buf, unsigned int len)
return trailing == 0;
}
-bool CCharsetConverter::isValidUtf8(const CStdString& str)
+bool CCharsetConverter::isValidUtf8(const std::string& str)
{
return isValidUtf8(str.c_str(), str.size());
}
-void CCharsetConverter::utf8logicalToVisualBiDi(const CStdStringA& strSource, CStdStringA& strDest)
+bool CCharsetConverter::utf8logicalToVisualBiDi(const std::string& utf8StringSrc, std::string& utf8StringDst)
{
- logicalToVisualBiDi(strSource, strDest, FRIBIDI_UTF8, FRIBIDI_TYPE_RTL);
+ return logicalToVisualBiDi(utf8StringSrc, utf8StringDst, FRIBIDI_UTF8, FRIBIDI_TYPE_RTL);
}
-void CCharsetConverter::SettingOptionsCharsetsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current)
+void CCharsetConverter::SettingOptionsCharsetsFiller(const CSetting* setting, std::vector< std::pair<std::string, std::string> >& list, std::string& current)
{
- vector<CStdString> vecCharsets = g_charsetConverter.getCharsetLabels();
+ vector<std::string> vecCharsets = g_charsetConverter.getCharsetLabels();
sort(vecCharsets.begin(), vecCharsets.end(), sortstringbyname());
list.push_back(make_pair(g_localizeStrings.Get(13278), "DEFAULT")); // "Default"
View
67 xbmc/utils/CharsetConverter.h
@@ -24,8 +24,9 @@
#include "settings/ISettingCallback.h"
#include "threads/CriticalSection.h"
#include "utils/GlobalsHandling.h"
-#include "utils/StdString.h"
+#include "utils/uXstrings.h"
+#include <string>
#include <vector>
class CSetting;
@@ -35,60 +36,62 @@ class CCharsetConverter : public ISettingCallback
public:
CCharsetConverter();
- virtual void OnSettingChanged(const CSetting *setting);
+ virtual void OnSettingChanged(const CSetting* setting);
void reset();
void clear();
- void utf8ToW(const CStdStringA& utf8String, CStdStringW &utf16String, bool bVisualBiDiFlip=true, bool forceLTRReadingOrder=false, bool* bWasFlipped=NULL);
+ bool utf8ToW(const std::string& utf8StringSrc, std::wstring& wStringDst,
+ bool bVisualBiDiFlip = true, bool forceLTRReadingOrder = false,
+ bool failOnBadChar = false, bool* bWasFlipped = NULL);
- void utf16LEtoW(const CStdString16& utf16String, CStdStringW &wString);
+ bool utf16LEtoW(const std::u16string& utf16String, std::wstring& wString);
- void subtitleCharsetToW(const CStdStringA& strSource, CStdStringW& strDest);
+ bool subtitleCharsetToW(const std::string& stringSrc, std::wstring& wStringDst);
- void utf8ToStringCharset(const CStdStringA& strSource, CStdStringA& strDest);
+ bool utf8ToStringCharset(const std::string& utf8StringSrc, std::string& stringDst);
- void utf8ToStringCharset(CStdStringA& strSourceDest);
- void utf8ToSystem(CStdStringA& strSourceDest);
+ bool utf8ToStringCharset(std::string& stringSrcDst);
+ bool utf8ToSystem(std::string& stringSrcDst, bool failOnBadChar = false);
- void utf8To(const CStdStringA& strDestCharset, const CStdStringA& strSource, CStdStringA& strDest);
- void utf8To(const CStdStringA& strDestCharset, const CStdStringA& strSource, CStdString16& strDest);
- void utf8To(const CStdStringA& strDestCharset, const CStdStringA& strSource, CStdString32& strDest);
+ bool utf8To(const std::string& strDestCharset, const std::string& utf8StringSrc, std::string& stringDst);
+ bool utf8To(const std::string& strDestCharset, const std::string& utf8StringSrc, std::u16string& utf16StringDst);
+ bool utf8To(const std::string& strDestCharset, const std::string& utf8StringSrc, std::u32string& utf32StringDst);
- void stringCharsetToUtf8(const CStdStringA& strSourceCharset, const CStdStringA& strSource, CStdStringA& strDest);
+ bool ToUtf8(const std::string& strSourceCharset, const std::string& stringSrc, std::string& utf8StringDst);
- bool isValidUtf8(const CStdString& str);
+ bool isValidUtf8(const std::string& str);
- bool isValidUtf8(const char *buf, unsigned int len);
+ bool isValidUtf8(const char* buf, unsigned int len);
- void ucs2CharsetToStringCharset(const CStdStringW& strSource, CStdStringA& strDest, bool swap = false);
+ bool wToUTF8(const std::wstring& wStringSrc, std::string& utf8StringDst, bool failOnBadChar = false);
+ bool utf16BEtoUTF8(const std::u16string& utf16StringSrc, std::string& utf8StringDst);
+ bool utf16LEtoUTF8(const std::u16string& utf16StringSrc, std::string& utf8StringDst);
+ bool ucs2ToUTF8(const std::u16string& ucs2StringSrc, std::string& utf8StringDst);
- void wToUTF8(const CStdStringW& strSource, CStdStringA &strDest);
- void utf16BEtoUTF8(const CStdString16& strSource, CStdStringA &strDest);
- void utf16LEtoUTF8(const CStdString16& strSource, CStdStringA &strDest);
- void ucs2ToUTF8(const CStdString16& strSource, CStdStringA& strDest);
+ bool utf8logicalToVisualBiDi(const std::string& utf8StringSrc, std::string& utf8StringDst);
- void utf8logicalToVisualBiDi(const CStdStringA& strSource, CStdStringA& strDest);
+ bool utf32ToStringCharset(const std::u32string& utf32StringSrc, std::string& stringDst);
- void utf32ToStringCharset(const unsigned long* strSource, CStdStringA& strDest);
+ std::vector<std::string> getCharsetLabels();
+ std::string getCharsetLabelByName(const std::string& charsetName);
+ std::string getCharsetNameByLabel(const std::string& charsetLabel);
+ bool isBidiCharset(const std::string& charset);
- std::vector<CStdString> getCharsetLabels();
- CStdString getCharsetLabelByName(const CStdString& charsetName);
- CStdString getCharsetNameByLabel(const CStdString& charsetLabel);
- bool isBidiCharset(const CStdString& charset);
+ bool unknownToUTF8(std::string& stringSrcDst);
+ bool unknownToUTF8(const std::string& stringSrc, std::string& utf8StringDst, bool failOnBadChar = false);
- void unknownToUTF8(CStdStringA &sourceDest);
- void unknownToUTF8(const CStdStringA &source, CStdStringA &dest);
+ bool toW(const std::string& stringSrc, std::wstring& wStringDst, const std::string& enc);
+ bool fromW(const std::wstring& wStringSrc, std::string& stringDst, const std::string& enc);
- void toW(const CStdStringA& source, CStdStringW& dest, const CStdStringA& enc);
- void fromW(const CStdStringW& source, CStdStringA& dest, const CStdStringA& enc);
-
- static void SettingOptionsCharsetsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current);
+ static void SettingOptionsCharsetsFiller(const CSetting* setting, std::vector< std::pair<std::string, std::string> >& list, std::string& current);
+private:
+ static const int m_Utf8CharMinSize, m_Utf8CharMaxSize;
};
XBMC_GLOBAL(CCharsetConverter,g_charsetConverter);
-size_t iconv_const (void* cd, const char** inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
+size_t iconv_const (void* cd, const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft);
#endif
View
2  xbmc/utils/RssReader.cpp
@@ -317,7 +317,7 @@ void CRssReader::fromRSSToUTF16(const CStdStringA& strSource, CStdStringW& strDe
{
CStdString flippedStrSource, strSourceUtf8;
- g_charsetConverter.stringCharsetToUtf8(m_encoding, strSource, strSourceUtf8);
+ g_charsetConverter.ToUtf8(m_encoding, strSource, strSourceUtf8);
if (m_rtlText)
g_charsetConverter.utf8logicalToVisualBiDi(strSourceUtf8, flippedStrSource);
else
View
2  xbmc/utils/StringUtils.cpp
@@ -341,7 +341,7 @@ CStdStringArray StringUtils::SplitString(const CStdString& input, const CStdStri
return result;
}
-vector<string> StringUtils::Split(const CStdString& input, const CStdString& delimiter, unsigned int iMaxStrings /* = 0 */)
+vector<string> StringUtils::Split(const std::string& input, const std::string& delimiter, unsigned int iMaxStrings /* = 0 */)
{
CStdStringArray result;
SplitString(input, delimiter, result, iMaxStrings);
View
2  xbmc/utils/StringUtils.h
@@ -72,7 +72,7 @@ class StringUtils
static CStdString Join(const std::vector<std::string> &strings, const CStdString& delimiter);
static int SplitString(const CStdString& input, const CStdString& delimiter, CStdStringArray &results, unsigned int iMaxStrings = 0);
static CStdStringArray SplitString(const CStdString& input, const CStdString& delimiter, unsigned int iMaxStrings = 0);
- static std::vector<std::string> Split(const CStdString& input, const CStdString& delimiter, unsigned int iMaxStrings = 0);
+ static std::vector<std::string> Split(const std::string& input, const std::string& delimiter, unsigned int iMaxStrings = 0);
static int FindNumber(const CStdString& strInput, const CStdString &strFind);
static int64_t AlphaNumericCompare(const wchar_t *left, const wchar_t *right);
static long TimeStringToSeconds(const CStdString &timeString);
View
2  xbmc/utils/Weather.cpp
@@ -306,7 +306,7 @@ void CWeatherJob::LoadLocalizedToken()
if (strEncoding.IsEmpty()) // Is language file utf8?
utf8Label=pChild->FirstChild()->Value();
else
- g_charsetConverter.stringCharsetToUtf8(strEncoding, pChild->FirstChild()->Value(), utf8Label);
+ g_charsetConverter.ToUtf8(strEncoding, pChild->FirstChild()->Value(), utf8Label);
if (!utf8Label.IsEmpty())
m_localizedTokens.insert(make_pair(utf8Label, id));
View
61 xbmc/utils/uXstrings.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/** @file utils/uXstrings.h
+ * Declarations of std::u16string and std::u32string for systems without those declarations
+ */
+#pragma once
+
+#include <string>
+
+#ifndef TARGET_WINDOWS
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif // HAVE_CONFIG_H
+
+#if !defined(HAVE_STD__U16STRING) || !defined(HAVE_STD__U32STRING)
+#if defined(HAVE_STDINT_H)
+#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif // defined(HAVE_INTTYPES_H)
+
+#ifndef HAVE_STD__U16STRING
+#ifndef HAVE_CHAR16_T
+typedef uint_least16_t char16_t;
+#endif // HAVE_CHAR16_T
+namespace std
+{
+ typedef basic_string<char16_t> u16string;
+}
+#endif // HAVE_STD__U16STRING
+
+#ifndef HAVE_STD__U32STRING
+#ifndef HAVE_CHAR32_T
+typedef uint_least32_t char32_t;
+#endif // HAVE_CHAR32_T
+namespace std
+{
+ typedef basic_string<char32_t> u32string;
+}
+#endif // HAVE_STD__U32STRING
+
+#endif // !defined(HAVE_STD__U16STRING) || !defined(HAVE_STD__U32STRING)
+#endif // TARGET_WINDOWS
Please sign in to comment.
Something went wrong with that request. Please try again.