www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - stdio.writef \u00a3

reply "John C" <johnch_atms hotmail.com> writes:
Anyone know why stdio.writef doesn't display the pound sign on Windows? 
Using "\u00A3" or "\&pound;" results in what looks like garbage.

The .NET Console class handles the character correctly. The latter uses 
GetStdHandle instead of stdout - perhaps that's something to do with it.

Short of writing my own console class, are there any workarounds? 
Feb 10 2006
parent reply Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
John C wrote:
 Anyone know why stdio.writef doesn't display the pound sign on Windows? 
 Using "\u00A3" or "\&pound;" results in what looks like garbage.
 
 The .NET Console class handles the character correctly. The latter uses 
 GetStdHandle instead of stdout - perhaps that's something to do with it.
 
 Short of writing my own console class, are there any workarounds? 
 
 
import std.stdio; void main() { writef("\u00A3"); } Works fine for me. However, it displays "┬ú" in cmd.exe since the shell can't handle Unicode. I think it uses windows-1252 or something as its codepage.* Anyhoo, if you direct the output to a text file you get a UTF-8 file with the pound sign, £, in it. I guess the .NET Console class internally converts to cmd.exe's encoding -if try to output something more exotic, like "\u3050", I don't think it should work even there. * "echo £" to a file and it gives the byte "9C". Beats me what encoding this is, but it sure ain't ISO or UTF ;)
Feb 10 2006
next sibling parent reply pragma <pragma_member pathlink.com> writes:
In article <dsiepe$19q8$1 digitaldaemon.com>, Deewiant says...
I guess the .NET Console class internally converts to cmd.exe's encoding -if
try to output something more exotic, like "\u3050", I don't think it should work
even there.
Well, that brings up an interesting point: shouldn't D be granted something similar, as to make unicode more universal in console apps? Perhaps something that lurks behind writef() that translates from various UTF encodings into the native codepage? - Eric Anderton at yahoo
Feb 10 2006
parent Sean Kelly <sean f4.ca> writes:
pragma wrote:
 In article <dsiepe$19q8$1 digitaldaemon.com>, Deewiant says...
 I guess the .NET Console class internally converts to cmd.exe's encoding -if
 try to output something more exotic, like "\u3050", I don't think it should
work
 even there.
Well, that brings up an interesting point: shouldn't D be granted something similar, as to make unicode more universal in console apps? Perhaps something that lurks behind writef() that translates from various UTF encodings into the native codepage?
I've been thinking it might simply make sense to use the wide version of all i/o functions behind the scenes. In fact, Windows even supports a "wmain" function that passes input parameters in as Unicode. Using these would be a heck of a lot easier than trying to convert to/from C code pages manually. Sean
Feb 10 2006
prev sibling next sibling parent Lars Ivar Igesund <larsivar igesund.net> writes:
Deewiant wrote:

 John C wrote:
 Anyone know why stdio.writef doesn't display the pound sign on Windows?
 Using "\u00A3" or "\&pound;" results in what looks like garbage.
 
 The .NET Console class handles the character correctly. The latter uses
 GetStdHandle instead of stdout - perhaps that's something to do with it.
 
 Short of writing my own console class, are there any workarounds?
 
 
import std.stdio; void main() { writef("\u00A3"); } Works fine for me. However, it displays "┬ú" in cmd.exe since the shell can't handle Unicode. I think it uses windows-1252 or something as its codepage.* Anyhoo, if you direct the output to a text file you get a UTF-8 file with the pound sign, £, in it. I guess the .NET Console class internally converts to cmd.exe's encoding -if try to output something more exotic, like "\u3050", I don't think it should work even there. * "echo £" to a file and it gives the byte "9C". Beats me what encoding this is, but it sure ain't ISO or UTF ;)
cmd.exe handles unicode if you tell it to, but that isn't necessarily easy to do.
Feb 10 2006
prev sibling parent "John C" <johnch_atms hotmail.com> writes:
"Deewiant" <deewiant.doesnotlike.spam gmail.com> wrote in message 
news:dsiepe$19q8$1 digitaldaemon.com...
 John C wrote:
 Anyone know why stdio.writef doesn't display the pound sign on Windows?
 Using "\u00A3" or "\&pound;" results in what looks like garbage.

 The .NET Console class handles the character correctly. The latter uses
 GetStdHandle instead of stdout - perhaps that's something to do with it.

 Short of writing my own console class, are there any workarounds?
import std.stdio; void main() { writef("\u00A3"); } Works fine for me. However, it displays "?ú" in cmd.exe since the shell can't handle Unicode. I think it uses windows-1252 or something as its codepage.* Anyhoo, if you direct the output to a text file you get a UTF-8 file with the pound sign, £, in it. I guess the .NET Console class internally converts to cmd.exe's encoding -if try to output something more exotic, like "\u3050", I don't think it should work even there. * "echo £" to a file and it gives the byte "9C". Beats me what encoding this is, but it sure ain't ISO or UTF ;)
Ah, and wprintf("\u009C") actually displays the pound sign £. Apparently the code page is called Western European (DOS). The Console class does, indeed, adjust its output internally to the console's code page.
Feb 10 2006