Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Printing a UTF8 code

by haj (Chaplain)
on Nov 08, 2019 at 13:31 UTC ( #11108476=note: print w/replies, xml ) Need Help??


in reply to Printing a UTF8 code

Actually, the following is correct:
open FO, ">test.txt"; binmode FO, ":utf8"; print FO "\x{00b9}";

If you see a strange character, then probably the program you're using to display your test file doesn't handle UTF-8 correctly, or must be told to do so.

I use to forget the correct syntax because I need them almost never. But a google search for "Perl unicode literals" reveals the nice article Perl Unicode Cookbook: Unicode Literals by Number by Tom Christiansen. That's how I did it right now.

Replies are listed 'Best First'.
Re^2: Printing a UTF8 code
by bobt_1234 (Initiate) on Nov 08, 2019 at 20:43 UTC
    Actually, that worked!
    Thanks!
    My mistake was using the wrong case. binmode FO, ":UTF8" # Does not work! binmode FO, ":utf8" # This works!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11108476]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-04-04 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (32 votes). Check out past polls.

    Notices?