Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

print Unicode characters

by kalyanrajsista (Scribe)
on Jun 14, 2010 at 07:22 UTC ( #844533=perlquestion: print w/ replies, xml ) Need Help??
kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I'm trying to print a string in my PDF along with a Unicode character like below

use strict; # sample string to be printed in PDF my $string = 'Number' . ' N with degree above';

How can I achieve this task.

Many Thanks

Comment on print Unicode characters
Download Code
Re: print Unicode characters
by moritz (Cardinal) on Jun 14, 2010 at 07:49 UTC
    How do you generate the PDF?

    Most PDF writing modules in Perl don't support arbitrary Unicode characters, so it's often not as easy as just putting a Unicode character into a string (which you'd do with charnames).

    Perl 6 - links to (nearly) everything that is Perl 6.

      I'm generating PDF using PDF::Template module. Any suggestions please if it doesn't support Unicode characters.

        As I understand it, PDF's "built-in" fonts don't support Unicode characters. So for anything outside the Latin-1 range you need to embed a font.

        The PDF::Reuse module now supports embedding TrueType fonts and outputting non ASCII characters using Perl's internal character string format.

Re: print Unicode characters
by Khen1950fx (Canon) on Jun 14, 2010 at 08:33 UTC
    Following moritz's advice, I used charnames like this. I hope it gets you going.
    #!/usr/bin/perl use strict; use charnames ':full'; print "\N{LATIN CAPITAL LETTER A}\n", "\N{LATIN SMALL LETTER A}\n";

      Thanks for the inputs and suggest me if I'm going in right way...

      #!/usr/bin/perl use strict; use charnames ':full'; print "\N{LATIN CAPITAL LETTER N}", "\N{DEGREE SIGN}\n";
        I'm not quite sure what you mean by "degree sign". I kept getting a "wide character in print" warning. However, I think that this is what you're after:
        #!/usr/bin/perl use strict; use encoding 'utf8'; use charnames ':full'; print "\N{LATIN CAPITAL LETTER N WITH DOT ABOVE}\n";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-12-25 15:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls