> Has anyone implemented unicode? I have the unicode standard, but find
> it's implementation independent descriptions too far removed. Can anyone
> give me some C examples for (let's keep it simple) transforming ascii
> to unicode and unicode to ascii.
At the simplest level.
ASCII to unicode:
unicode_char = ascii_char;
Unicode to ASCII:
if( unicode_char <= 0xFF )
ascii_char = unicode_char;
[ASCII is a subset of UNICODE consisting of all characters <= 0xFF.
ISO8859-1 is a subset of UNICODE consisting of all characters <= 0x100]
Beyond the simplest level it gets complex. The wide character set supported
by your C compiler may or may not be unicode. If it has then you have a good start
with the conversion routines it provides. The new C9X standard is proposing
some additional support for using unicode numberings to describe character literals
and extra characters in variable names. X windows has some wide character support,
I am not sure if it is unicode based or not.
Encoding convertion is not too difficult, it is just a matter of lots and lots
of conversion tables. Displaying unicode is more difficult. Apart from things
like the direction of writing different character sets and that some unicode
characters can be regarded as combinations of others, unicode is a character
encoding, not a glyph encoding. Some characters in some languages are displayed
usign different glyphs in different contexts (for example at the end of the word).
This requires support from the font and its display system for it to work.
I am not sure what is available here.
Look out for the various internationalization FAQs:
Programming for Internationalization FAQ
Finding Fonts for Internationalization FAQ
Philips Semiconductors Ltd
Southampton SO15 0DJ +44 (01703) 316431
United Kingdom My views are my own.
Do you use ISO8859-1? Yes if you see ? as copyright, as division and ? as 1/2.