Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Printing a UTF8 code

by hippo (Chancellor)
on Nov 08, 2019 at 13:53 UTC ( #11108477=note: print w/replies, xml ) Need Help??


in reply to Printing a UTF8 code

print FO "\x{00b9}"; # Outputs a strange character (the code for 00b9 is a superscript 1}

This works fine for me on Perl v5.20.3:

$ cat uniprint.pl 
#!/usr/bin/env perl 
use strict;
use warnings;

open my $out, '>:utf8', 'test.txt';
print $out "Hello\x{00b9}\n";
close $out;
$ ./uniprint.pl 
$ cat test.txt
Hello¹
$ hexdump test.txt
0000000 6548 6c6c c26f 0ab9                    
0000008
$

If you get different output from the hexdump, that would be informative to see. If the hexdump is the same, but the cat output doesn't match then your terminal or locale is probably to blame.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2020-04-05 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (35 votes). Check out past polls.

    Notices?