Author: Ulrich EckhardtUlrich Eckhardt
Date: Jan 28, 2008 00:15
>>>Does anybody know a way to convert Windows code page 1252 to UTF-8 in
>>>C++?
>>
>>>The idea is ... I have an app that reads files off a user's HARD DRIVE
>>>... assume the user is in the US, so the FILE NAMES ARE 1252 encoded ...
Assuming the user uses MS Windows NT, 2k etc the filenames are encoded in
UCS2/UTF-16, available via the wchar_t win32 APIs.
>>>I have to insert it into a database that expects UTF-8. Â Does anybody
>>>know a way to convert the Windows 1252 encoding to UTF-8?
MultibyteToWideChar using CP1252 and the the reverse using UTF-8. Note that
this can be made to work according to the user's current settings, so if I
set my codepage to IS08859-15 (not unusual for a German) it would work just
the same for me. Complete Unicode awareness and use of full-Unicode capable
APIs would be a better choice though, maybe even I have some Chinese
letters in my filenames...
> olsize_t USTR_CP1252_To_Utf8(char* dst_str, olsize_t dst_len,
> const char* src_str, olsize_t src_len)
[...conversion function...]
|