in reply to £ symbols
why is it when i print a £(pound) symbol out in perl it comes out as a ? (question mark)?
The answer depends on a lot of things. Since you're using macosx, I'll assume you're using the nifty Terminal app, with the character set encoding configured to the default (utf8 -- if you check the "Window preferences / Display" menu, you can change that setting, e.g. to "ISO Latin 1", if you want to).
If your terminal window is using utf8, then you should see a £(pound) symbol rather than a question mark if you do this:
If your text containing the pound sign is coming from some external source, then you have to know what encoding is being used by that source -- then either convert it to utf8, or not, but make sure that the character encoding of the agrees with that of the output file handle.binmode STDOUT, ":utf8"; print "Here is the pound sign: \xA3\n";
If you don't want to set STDOUT to utf8 like that, then you'll probably want to set your terminal to use ISO Latin 1 (as explained above).
If the output file handle has not been set to utf8 mode, then byte/character values in the range 128-255 (0x80-0xff) will be output as-is without conversion to utf8 encoding, and in that case, you just want to be sure that the whatever uses that output knows to expect non-utf8 data.
But if you want ut8 output, you have to tell perl that the file handle is supposed to do that (using binmode).
(updated to finish the paragraph that followed the code snippet).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: £ symbols
by Yoda_Oz (Sexton) on Jan 11, 2007 at 23:20 UTC | |
by graff (Chancellor) on Jan 12, 2007 at 02:34 UTC |