Reputation: 11
my $star = 'इस परीक्षण के लिए है';
I want to print this string as it is using encoding.
Upvotes: 1
Views: 434
Reputation: 126762
You need the statement
use utf8;
at the top of your program to tell perl that the script is encoded in UTF-8. You can also write
use open qw/ :std :encoding(UTF-8) /;
to make UTF-8 the default output encoding
Your terminal must be expecting UTF-8 output. On Linux you should check the LC_TYPE
environment variable
echo $LC_CTYPE
This should normally be UTF-8
but you can change it if not
On Windows this is done with code pages. For UTF-8 you need code page 65001. Use the chcp
command to check and alter it
Now, provided your terminal is using a font that covers the characters you want to display, you should be able to just print $star
to have the text appear on your terminal
Upvotes: 4