Prev Previous Post   Next Post Next
Old 2nd March 2009, 14:34   #11
AxelMock
Junior Member
 
Join Date: Apr 2007
Location: Seltz, France
Posts: 46
New Unicode.dll

Quote:
Originally posted by akopts
I need output file in UTF-8. There is an NSIS plugin which converts between ASCII and various Unicodes, but not between UTF-16 and UTF-8.
Since I had to cope with the Unicode.dll last week, I added the missing routine FileUnicode2UTF8 to Unicode.dll.


int WideCharToMultiByte(
__in UINT CodePage,
__in DWORD dwFlags,
__in LPCWSTR lpWideCharStr,
__in int cchWideChar,
__out LPSTR lpMultiByteStr,
__in int cbMultiByte,
__in LPCSTR lpDefaultChar,
__out LPBOOL lpUsedDefaultChar
);

According to Microsoft's documentation WideChar2MultiByte should return the BufferSize needed if parameter cbMultiByte is 0, i always got 0.

So to convert a file to UTF-8 I make the buffer as large as the inputfile (Unicode-16) and if the function returns "ERROR_INSUFFICIENT_BUFFER" I reallocate the buffer with double the size and repeat.

I hope It will be of use.
Axel
Attached Files
File Type: zip unicode_v1.1.zip (9.6 KB, 1050 views)
AxelMock is offline   Reply With Quote
 
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump