ANSI - output with phobos
Juan Jose Comellas
jcomellas at gmail.com
Wed Apr 4 07:05:30 PDT 2007
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.
For more information I suggest reading this:
http://en.wikipedia.org/wiki/Utf-8
http://en.wikipedia.org/wiki/Utf-16
me wrote:
> for(char c = 0; c < c.max; c++)
> writefln(c);
>
> In a not too distant past the above code could produce the entire ANSI
> table, however this is not the case today. Today it peters out at 127 and
> any code beyond that cannot be desplayed. The error message produced is:
>
> Error: 4invalid UTF-8 sequence
>
> Please provide some guidance on how to accomplish this in present D.
>
> Thanks,
> Drew
More information about the Digitalmars-d-learn
mailing list