ANSI - output with phobos

Deewiant deewiant.doesnotlike.spam at gmail.com
Wed Apr 4 08:00:40 PDT 2007


Juan Jose Comellas wrote:
> The problem is that the 'char' type can only contain valid UTF-8
> *characters*. A character in UTF-8 can be composed of 1 to 4 *bytes*, and
> not all of the values a byte can take are valid in UTF-8. In fact, most of
> the byte values above 127 are not valid. You have two options: 1) use the
> wchar type (the Latin 1/ISO8859-1 character set is very similar to ANSI and
> all of its characters are 2 byte-wide when mapped to the UTF-16 character
> set); 2) manually convert the 'ANSI' value into UTF-8.

3) Use ubyte (or use char, but be careful about what functions you pass
non-UTF-8 chars to), and print using the C standard library.

One might have to output a string without knowing its encoding, thus making it
impossible to convert it to a UTF encoding reliably.

-- 
Remove ".doesnotlike.spam" from the mail address.


More information about the Digitalmars-d-learn mailing list