On Thu, May 29, 2003 at 07:48:53PM +0200, Marcus Lundblad wrote:
> I'm currently hacking on the support for combining characters, as
> discussed before.
> I've written a piece of code to performe combining into precomposed forms
> (according to Unicode specifications) that operate on 16-bit values.
> Now I wonder how to invoke this from Flocale.c
> There's a function to convert between charsets. Can I use this to convert
> to 16-bit unicode (UCS-2)?
> I'm not sure what arguments to use for this. Or should I use the functions
> to convert to UTF-8 first, and then use UTF-8 in my code (add conversion
> internally in my function, I know how to do this, but I guess Iconv can do
> it directly).
> 

iconv can surely convert in between UTF-8 and USC-2 and you can
surely use FiconvCharsetToCharset to do the conversion.
FiconvCharsetToCharset is a bit complex because you need to pass
FlocaleCharset and not simple "charset"(the reason is portability,
e.g., some iconv use "USC-2" other (non gnu) "USC2").  Also, note that
for conversion from charset A to charset B, FiconvCharsetToCharset
converts from A to UTF-8 and from UTF-8 to B (gnu iconv do that and
this gives better result with some others iconv).  So, for using
FiconvCharsetToCharset, you should have to "construct"
FLCIconvUsc2Charset exactly the same way FLCIconvUtf8Charset is
constructed in Ficonv.c.  Then, you can write down direct converter
FiconvUsc2ToCharset and FiconvCharsetToUsc2 as FiconvUtf8ToCharset and
FiconvCharsetToUtf8.
Of course, you should also have a FlocaleCharset for the other charset,
but this should happen as the "in" charset is given by the font (see
FlocaleEncodeString).

However, as USC-2 <--> UTF-8 conversions are easy (and fast), I think
the other alternative is ok (maybe faster and with no portability
problem concerning the "USC-2" name). Note that there are already
two functions which perform conversion from UTF-8 to USC-2 (under
certain type) FftUtf8ToFftString16 and FlocaleUtf8ToUnicodeStr2b. 

Regards, Olivier
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to