Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / October 2006



Tip: Looking for answers? Try searching our database.

encode qp a Unicode string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nobumi Iyanaga - 07 Oct 2006 14:57 GMT
Hello,

I have a Unicode string that I would like to convert into quoted-
printable encoding, but if I do:

#!/usr/bin/perl

use utf8;
use MIME::QuotedPrint;

my $unicode_string = "xxx" # where I have real Unicode string, for  
example Japanese characters...
$encoded = encode_qp($unicode_string);
print "qp: $encoded\n";

I get the error message:

"Wide character in subroutine entry"

If I comment out the "use utf8", I get the right result, but I need  
it for my script.

I tried also to convert the Unicode string to data using the code

$native_string  = pack("C*", unpack("U*", $Unicode_string));

that I found in perluniintro, but I get the error message:

"Character in 'C' format wrapped in pack"

What am I doing wrong?

Thank you very much in advance for any help.

Best regards,

Nobumi Iyanaga
Tokyo,
Japan
Gisle Aas - 07 Oct 2006 15:04 GMT
> What am I doing wrong?

You did not read 'perldoc MIME::QuotedPrint' to the end :)

|    Perl v5.8 and better allow extended Unicode characters in strings.  Such strings
|    cannot be encoded directly, as the quoted-printable encoding is only defined for
[quoted text clipped - 6 lines]
|        $encoded = encode_qp(encode("UTF-8", "\x{FFFF}\n"));
|        print $encoded;

Regards,
Gisle
Nobumi Iyanaga - 07 Oct 2006 15:17 GMT
Hello Gisle,

>> What am I doing wrong?
>
[quoted text clipped - 13 lines]
> |        $encoded = encode_qp(encode("UTF-8", "\x{FFFF}\n"));
> |        print $encoded;

Ah, thank you very much indeed!

Best regards,

Nobumi Iyanaga
Tokyo,
Japan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.