Hi, thanos1983. I'd like to point out, that use of non-latin1 characters in Perl source, without use utf8; is misleading. Perhaps your example might be modified to this (note the differences, while output is deceptively the same):
#!/usr/bin/perl use strict; use warnings; use URI::Escape; use feature 'say'; use utf8; use Encode qw/ encode decode /; binmode STDOUT, ':utf8'; my $str = "Character one: ω character two: ∞"; my $hex_code = uri_escape_utf8( $str ); say $hex_code; my $string = decode 'UTF-8', uri_unescape( $hex_code ); say $string; __END__
To answer Anonymous Monk's direct question:
use strict; use warnings; use PDF::API2; use URI::Escape; use Encode qw/ decode /; my $percent_encoded_str = '%CF%89%20%E2%88%9E'; my $octets = uri_unescape $percent_encoded_str; my $proper_unicode_str = decode 'UTF-8', $octets; my $pdf = PDF::API2-> new; my $page = $pdf-> page; my $text = $page-> text; my $ttf_font = $pdf-> ttfont( 'DejaVuSans.ttf' ); $text-> font( $ttf_font, 20 ); $text-> translate( 50, 700 ); $text-> text( $proper_unicode_str ); $pdf-> saveas( 'test.pdf' );
In reply to Re^4: PDF::API2 printing non ascii characters
by vr
in thread PDF::API2 printing non ascii characters
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |