Displaying non UTF-8 8 bit character codes with writefln()
Regan Heath
regan at netmail.co.nz
Fri Oct 5 07:04:35 PDT 2007
Stewart Gordon wrote:
> "Regan Heath" <regan at netmail.co.nz> wrote in message
> news:fe5d88$15l$1 at digitalmars.com...
> <snip>
>> 1. avoid the valid utf-8 cahracter check.
>> 2. make the console display utf-8 correctly.
>>
>> To achive #1 you've gotta use printf, eg.
>> printf("%c\n", 230);
>
> No I gottan't. I could use putchar, puts or OutputStream.writeString
> for example.
Sure, except the OP wanted formatting. End of the day, as long as you
know what you're doing using printf isn't going to kill you.
> <snip>
>>> This misses the point slightly. The user shouldn't have to change
>>> the codepage just to get someone else's application to work properly.
>>
>> Sadly, if the application is outputting UTF-8 you don't have a choice.
>
> But how many DOS or Windows console apps in the real world output UTF-8?
Everything written in D using writefln from phobos ;)
Even if you're only outputting ASCII characters (a subset of UTF-8 - as
I'm sure you know) you have the ability to output the full range of
UTF-8 codepoints and really we need a console which can handle that.
> Presumably not many, considering that no versions of DOS and only a few
> versions of Windows support it. There's also a causal loop in that even
> modern Windows versions don't come with the console code page set to
> 65001 by default. I don't know what is likely to break this loop, but I
> doubt that the restrictiveness of one language's standard library is
> going to do it.
True. I wonder what the vista console defaults to? Are they still
using local code pages or are they using UTF-8 or UTF-16 (perhaps more
likely)
>>> What you want is my utility library:
>>> http://pr.stewartsplace.org.uk/d/sutil/
>>
>> Cool. You're converting UTF-8 to the console code page I assume.
>
> Exactly. (Well, as exactly as is possible under the constraints.)
:)
Regan
More information about the Digitalmars-d-learn
mailing list