Tugger the SLUGger!SLUG Mailing List Archives

[coders] Re: Converting a UTF-8 string to a wchar_t (in C)


On 14/12/2006, at 1:15 AM, Andre Pang wrote:

2. Use the stupendously painful iconv() interface with a iconv_t from "UTF-8" to "WCHAR_T".

For future reference, there's a file in the libiconv distribution's extras/ directory named iconv_string.h (public domain licensed). This gives a saner interface to iconv():

  extern int iconv_string (const char* tocode,
                           const char* fromcode,
                           const char* start,
                           const char* end,
                           char** resultp,
                           size_t* lengthp);

(Of course, I only find out about this afterwards :).


--
% Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>