Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: symbols

by Melly (Hermit)
on Jan 11, 2007 at 15:35 UTC ( #594180=note: print w/replies, xml ) Need Help??

in reply to symbols

The pound symbol is part of the extended ascii set, which is why it causes you problems.... try

print chr(156)

(156 is the ascii value for '')

map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
Tom Melly,

Replies are listed 'Best First'.
Re^2: symbols
by Tux (Abbot) on Jan 11, 2007 at 16:02 UTC
    But the pound is not 156 in every coding :)
    e.g. the utf8 codepoint for the pound is U00A3, which is 163 in dec, not 156.

    See pound sign

    It is 163 (0x00a3) in 8859-1, 8859-13, 8859-14, 8859-15, 8859-3, 8859-7, 8859-8, 8859-9, CP1252, CP1253, CP1254, CP1255, CP1256, CP1257, CP1258, CP864, ROMAN, SAMI_WIN, SAMI_MAC, and CENTEURO
    It is 156 (0x009c) in CP437, CP775, CP850. CP857, CP860, CP861, CP862, CP863, CP865, CP869, CP1116, and VENTURA_INT
    It is 177 (0x00b1) in CP1122

    Maybe it is better to use UTF8 after all
    # perl -C2 -le'use charnames qw(:full); print "\N{POUND SIGN}"'
Re^2: symbols
by Thelonius (Priest) on Jan 11, 2007 at 16:12 UTC
    In most character sets, including iso-8859-1 and Unicode, the pound symbol is 163 decimal, or 0xA3 hexadecimal, so you should use "chr(163)". If you use the correct encoding on the output, that will be translated to the correct character.

    E.g. this

    perl -e 'binmode STDOUT, ":encoding(cp437)"; print chr(0xA3), "\n"' \ | od -c -t x1 0000000 234 \r \n 9c 0d 0a
    (Code page 437 is a common code page for a DOS box on Windows, but it can be changed with CHCP.)

    and this

    perl -e 'binmode STDOUT,":encoding(latin-1)"; print chr(0xA3),"\n"' \ | od -c -t x1
    0000000 243 \r \n a3 0d 0a

    But, note that 156 (0x9c) does not work with the Encode translations:

    perl -e 'binmode STDOUT, ":encoding(cp437)"; print chr(0x9C), "\n"' \ | od -c -t x1
    "\x{009c}" does not map to cp437. 0000000 \ x { 0 0 9 c } \r \n 5c 78 7b 30 30 39 63 7d 0d 0a

    If you are outputting to HTML, you also have to make sure the Content-type charset gets set correctly or output the characters as entities, e.g. £ or £

Re^2: symbols
by gaal (Parson) on Jan 11, 2007 at 16:13 UTC
    156 is not the ASCII value for anything. ASCII is 7 bit, and only goes to 127.

    163 in Unicode and Latin-1 (aka ISO-8859-8) is the pound sign.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://594180]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-05-25 07:10 GMT
Find Nodes?
    Voting Booth?