//----------------------------------------------------------------------------- // Purpose: converts an unicode string to an english string //----------------------------------------------------------------------------- int ILocalize::ConvertUnicodeToANSI(const wchar_t *unicode, char *ansi, int ansiBufferSize) { #ifdef POSIX return Q_UnicodeToUTF8(unicode, ansi, ansiBufferSize); #else int result = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, ansi, ansiBufferSize, NULL, NULL); ansi[ansiBufferSize - 1] = 0; return result; #endif }
char *CCode_Editor::ReadSnippet( text_cursor c0, text_cursor c1, bool bAddCR ) { if ( c1 < c0 ) return NULL; wchar_t *pW; m_pCodeWindow->Selection_Copy( &c0, &c1, &pW, bAddCR ); if ( !pW ) return NULL; bool bValid = false; wchar_t *pFindChar = pW; while ( *pFindChar && !bValid ) { if ( *pFindChar != L' ' && *pFindChar != L'\t' && *pFindChar != L'\r' && *pFindChar != L'\n' ) bValid = true; pFindChar++; } char *pC = NULL; if ( bValid ) { int len = Q_wcslen( pW ) + 1; pC = new char[ len ]; Q_UnicodeToUTF8( pW, pC, len ); } delete [] pW; return pC; }