in reply to Re^3: PDF::API2 printing non ascii characters
in thread PDF::API2 printing non ascii characters

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' );

Replies are listed 'Best First'.
Re^5: PDF::API2 printing non ascii characters
by thanos1983 (Parson) on Mar 14, 2018 at 12:16 UTC

    Hello vr,

    Indeed I got mislead due to the output. You are absolutely right. Thanks for the note.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re^5: PDF::API2 printing non ascii characters
by Anonymous Monk on Mar 13, 2018 at 16:38 UTC

    Wow, thanks!!!

    I can finally output those non ascii characters correctly in pdf :)))