Displaying non UTF-8 8 bit character codes with writefln()
Graham
GC
Thu Oct 4 08:08:56 PDT 2007
Regan Heath Wrote:
> Try printf and saving the file as a UTF-8 encoded text file...
>
> --[b5.d]--
> import std.stdio;
>
> void main()
> {
> printf("\µ\n");
> printf("\u00B5\n");
> printf("\xB5\n"); //doesn't output anything
> writefln("µ");
> }
>
> Using this source saved as b5.d as a UTF-8 encoded text file (IMPORTANT)
> I can set my command prompt font to "Lucida Console" and execute the
> following commands:
>
> E:\D\src\tmp>chcp 65001
> Active code page: 65001
>
> E:\D\src\tmp>dmd -run b5.d
> µ
> µ
> µ
>
> The 3rd printf doesn't output anything, not sure why, the others all
> output the same character.
>
> chcp 65001 changes to UTF-8 code page :)
>
> Regan
Thanks, I was hoping for something more elegant but if all char variables in phobos have to be UTF-8 I guess this is the only way.
More information about the Digitalmars-d-learn
mailing list