?
Solved

Perl and Celsius Symbo

Posted on 2011-02-18
6
Medium Priority
?
474 Views
Last Modified: 2012-06-21
Hiya

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

John
0
Comment
Question by:IssacJones
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:group0
ID: 34928244
print "\xB0";
0
 

Author Comment

by:IssacJones
ID: 34945276
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
 
LVL 5

Expert Comment

by:group0
ID: 34946336
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:IssacJones
ID: 34946370
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
 

Author Comment

by:IssacJones
ID: 34946482
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
 
LVL 5

Accepted Solution

by:
group0 earned 1000 total points
ID: 34946609
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question