openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] RE: UNICODE support in openexr file I/O


From: Lutz Latta
Subject: Re: [Openexr-devel] RE: UNICODE support in openexr file I/O
Date: Thu, 26 Jan 2006 12:44:34 -0800
User-agent: Thunderbird 1.5 (Windows/20051201)

Your test 4 is basically the correct approach, but you need to change the MultiByteToWideChar argument CP_ACP (your system's ANSI code page) to CP_UTF8. Additionally don't cast the second argument to _wfopen, specify it as wide string with L"wb", or use CreateFileW on Windows.
   Lutz


Nick Porcino wrote:
TEST FOUR - _wfopen + UTF-8 -> 16 conversion

Finally:


using std::wstring;

wstring toWideString( const char* pStr , int len )
{
// figure out how many wide characters we are going to get int nChars = MultiByteToWideChar( CP_ACP , 0 , pStr , len , NULL , 0 ) ; if ( len == -1 ) -- nChars ; if ( nChars == 0 )
        return L"" ;

    wstring buf ;
buf.resize( nChars ) ; MultiByteToWideChar( CP_ACP , 0 , pStr , len , const_cast<wchar_t*>(buf.c_str()) , nChars ) ;
    return buf ;
}

int _tmain(int argc, _TCHAR* argv[])
{
    wstring wname = toWideString(name, strlen(name));
    FILE* x = _wfopen(wname.c_str(), (const wchar_t*)"wb");
        return 0;
}

äºéƒ½å¸‚#

(random junk)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]