ANSI - output with phobos

Derek Parnell derek at nomail.afraid.org
Tue Apr 3 18:12:56 PDT 2007


On Tue, 03 Apr 2007 20:26:49 -0400, me wrote:

> 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
> 

You seem to be wanting to display the characters of the console's current
code-page.

> I am aware that printf() can still be used to achieve the desired result.
Yes, because it's a C routine and not D.

So I guess, the issue you are trying to resolve is how to convert code-page
characters into UTF-8 form. Character values 128-255 are displayed on the
Windows console using the console's current code-page to select the
appropriate glyph. To get the same glyph to display using Unicode (which is
the only character set that D supports) would mean that you have to set the
console to a Unicode "code-page" and manually convert the character values
from the code-page you were assuming, to the equivalent Unicode value. 

Not a trivial task at all.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Justice for David Hicks!"
4/04/2007 11:05:14 AM


More information about the Digitalmars-d-learn mailing list