Commit be72325b authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

utf8 conversion (linux)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58184 954022d7-b5bf-4e40-9824-e11837661b57
parent 8002985d
......@@ -149,7 +149,20 @@ namespace XmlUtils
BOOL SaveToFile(const CString& strFilePath, BOOL bEncodingToUTF8 = FALSE)
{
#ifdef _WIN32
// win32 unicode and multibyte strings
FILE* pFile = _tfopen(strFilePath, _T("wt"));
#else
// *nix build
#ifdef _UNICODE
std::string sFilePathUtf8 = stringWstingToUtf8String (strFilePath);
FILE* pFile = fopen(sFilePathUtf8.c_str(), "wt");
#else
// path is already utf8
std::string sFilePathUtf8 = strFilePath;
FILE* pFile = fopen(sFilePathUtf8.c_str(), "wt");
#endif
#endif
if (!pFile)
return FALSE;
......@@ -171,13 +184,20 @@ namespace XmlUtils
#ifdef _UNICODE
CStringA EncodingUnicodeToUTF8()
{
int nLength = m_str.GetLength();
// Encoding Unicode to UTF-8
CStringA saStr;
WideCharToMultiByte(CP_UTF8, 0, m_str.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
saStr.ReleaseBuffer();
return saStr;
#ifdef _WIN32
int nLength = m_str.GetLength();
// Encoding Unicode to UTF-8
CStringA saStr;
WideCharToMultiByte(CP_UTF8, 0, m_str.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
saStr.ReleaseBuffer();
return saStr;
#else
std::string sStrTempUtf8 = stringWstingToUtf8String (m_str);
CStringA saStr = sStrTempUtf8;
return saStr;
#endif
}
#else
CString EncodingASCIIToUTF8()
......@@ -216,7 +236,11 @@ namespace XmlUtils
{
char str[33];
_itoa(Value, str, Base);
#ifdef _WIN32
_itoa(Value, str, Base);
#else
itoa(Value, str, Base);
#endif
m_str += str;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment