Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

Perl and Celsius Symbo

Hiya

Can anybody tell me how to print to the console the Celsius symbol?

John
0
IssacJones
Asked:
IssacJones
  • 3
  • 3
1 Solution
 
group0Commented:
print "\xB0";
0
 
IssacJonesAuthor Commented:
Hi group0

That does not work for me. I simply get a character that looks like a hatched rectangle. I am using Windows 7.

John
0
 
group0Commented:
Apparently extended ascii and unicode character set issues are fairly common on Windows.

Can you try running the following:
use utf8;
print "1: \x{00B0}\n";
print "2: " . chr(0x00B0) . "\n";
print "3: \x{00F8}\n";
print "4: " . chr(0x00F8) . "\n";

Open in new window


You can also try entering ALT-0176 or ALT-248 and see if either outputs the proper symbol when editing the source.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
IssacJonesAuthor Commented:
hi group0

3 and 4 work!!!!

I take it that there is some connection between 0176/248 and 00B0 and 00F8. What is the connection and how to I convert between the two?

John
0
 
IssacJonesAuthor Commented:
Is there a way I can write the Perl code so it uses numbers like 248 (which I recognise) instead of the hex equivalent?

John
0
 
group0Commented:
Yes, 176 in hex is B0 and 248 is F8.  To use the decimal version, use chr() without a leading 0x:

print chr(248) . "\n";

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now