Автор: ycxw2012
Дата сообщения: 16.04.2012 02:51
[more] 我尝试修改了shell.cpp 和 utf.cpp,竟然显示正常了! :)
请你帮我看看,我修改了这几处,会不会出现其他问题呢?
struct W2MB
{
W2MB( const wchar_t *src, int cp )
: buffer(0)
{
int len = ::WideCharToMultiByte(CP_ACP, 0, src, -1, 0, 0, 0, 0 );
if ( len )
{
buffer = new char[len];
len = ::WideCharToMultiByte(CP_ACP, 0, src, -1, buffer, len, 0, 0 );
}
}
~W2MB()
{ delete[] buffer; }
const char *c_str() const
{ return buffer; }
private:
char *buffer;
};
struct MB2W
{
MB2W( const char *src, int cp )
: buffer(0)
{
int len = ::MultiByteToWideChar(CP_ACP, 0, src, -1, 0, 0 );
if ( len )
{
buffer = new wchar_t[len];
len = ::MultiByteToWideChar(CP_ACP, 0, src, -1, buffer, len );
}
}
~MB2W()
{ delete[] buffer; }
const wchar_t *c_str() const
{ return buffer; }
private:
wchar_t *buffer;
};
wchar_t* StringFromUTF8(const char *s) {
if(!s) return NULL;
size_t sLen = s ? strlen(s) : 0;
size_t wideLen = MultiByteToWideChar(CP_ACP, 0, s, -1, 0, 0 );
wchar_t* vgc = new wchar_t[wideLen + 1];
size_t outLen = MultiByteToWideChar(CP_ACP, 0, s, -1, vgc, wideLen );
vgc[outLen] = 0;
return vgc;
}
char* UTF8FromString(const std::wstring &s) {
size_t sLen = s.size();
size_t narrowLen = WideCharToMultiByte(CP_ACP, 0, s.c_str(), -1, 0, 0, 0, 0 );
char* vc = new char[narrowLen + 1];
WideCharToMultiByte(CP_ACP, 0, s.c_str(), -1,vc, narrowLen, 0, 0 );
return vc;
}
// -------------------------------------------------------------------
[/more]