ANSI - output with phobos

Daniel Keep daniel.keep.lists at gmail.com
Wed Apr 4 07:28:24 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.
> 
> For more information I suggest reading this:
> 
> http://en.wikipedia.org/wiki/Utf-8
> http://en.wikipedia.org/wiki/Utf-16

Here's another one (shameless plug):

http://www.prowiki.org/wiki4d/wiki.cgi?DanielKeep/TextInD

	-- Daniel

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

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/


More information about the Digitalmars-d-learn mailing list