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 ...@@ -149,7 +149,20 @@ namespace XmlUtils
BOOL SaveToFile(const CString& strFilePath, BOOL bEncodingToUTF8 = FALSE) BOOL SaveToFile(const CString& strFilePath, BOOL bEncodingToUTF8 = FALSE)
{ {
#ifdef _WIN32
// win32 unicode and multibyte strings
FILE* pFile = _tfopen(strFilePath, _T("wt")); 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) if (!pFile)
return FALSE; return FALSE;
...@@ -171,6 +184,7 @@ namespace XmlUtils ...@@ -171,6 +184,7 @@ namespace XmlUtils
#ifdef _UNICODE #ifdef _UNICODE
CStringA EncodingUnicodeToUTF8() CStringA EncodingUnicodeToUTF8()
{ {
#ifdef _WIN32
int nLength = m_str.GetLength(); int nLength = m_str.GetLength();
// Encoding Unicode to UTF-8 // Encoding Unicode to UTF-8
...@@ -178,6 +192,12 @@ namespace XmlUtils ...@@ -178,6 +192,12 @@ namespace XmlUtils
WideCharToMultiByte(CP_UTF8, 0, m_str.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, m_str.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
saStr.ReleaseBuffer(); saStr.ReleaseBuffer();
return saStr; return saStr;
#else
std::string sStrTempUtf8 = stringWstingToUtf8String (m_str);
CStringA saStr = sStrTempUtf8;
return saStr;
#endif
} }
#else #else
CString EncodingASCIIToUTF8() CString EncodingASCIIToUTF8()
...@@ -216,7 +236,11 @@ namespace XmlUtils ...@@ -216,7 +236,11 @@ namespace XmlUtils
{ {
char str[33]; char str[33];
#ifdef _WIN32
_itoa(Value, str, Base); _itoa(Value, str, Base);
#else
itoa(Value, str, Base);
#endif
m_str += str; 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