Message from discussion
encode from_to error
Newsgroups: perl.unicode
Path: g2news2.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!171.64.64.130.MISMATCH!usenet.stanford.edu!nntp.perl.org
Return-Path: <nye...@ptc.com>
Mailing-List: contact perl-unicode-h...@perl.org; run by ezmlm
Delivered-To: mailing list perl-unic...@perl.org
Delivered-To: moderator for perl-unic...@perl.org
by x6.develooper.com with SMTP; 17 Sep 2009 17:14:22 -0000
Delivered-To: perl-unic...@perl.org
X-Spam-Status: No, hits=-4.0 required=8.0
tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED
X-Spam-Check-By: la.mx.develooper.com
by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 17 Sep 2009 10:14:14 -0700
X-IronPort-AV: E=Sophos;i="4.44,404,1249272000";
d="scan'208,217";a="53249374"
by irp2.ptc.com with ESMTP; 17 Sep 2009 13:14:04 -0400
Thu, 17 Sep 2009 13:14:04 -0400
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01CA37BA.40224C8A"
Subject: encode from_to error
Date: Thu, 17 Sep 2009 13:14:01 -0400
Message-ID: <E42DC078973EEA459D7ED61BA6EB19BC02659CCF@HQ-MAIL3.ptcnet.ptc.com>
Thread-Topic: encode from_to error
thread-index: Aco3ukAOLCL5oBFARQ6wesAbHmmJLw==
To: <perl-unic...@perl.org>
X-OriginalArrivalTime: 17 Sep 2009 17:14:04.0532 (UTC) FILETIME=[4210C340:01CA37BA]
X-Virus-Checked: Checked
Approved: n...@nntp.perl.org
From: nye...@ptc.com (Nick Yebba)
------_=_NextPart_001_01CA37BA.40224C8A
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello,
=20
We recently moved some Perl applications onto a new machine and one is
dying with an encoding error. These previously worked fine on the older
machine with older perl encoding modules. What I am trying to do is
query an oracle database and pull the string then encode to the proper
encoding(based on language). It works for all languages except Asian
ones. In the below code I am pulling some Korean text and trying to
encode to the Korean charset (this is needed so we can then send the
text in an email). When I do this I get the following error. The
exact code previously worked before moving to the newer machine. Any
insight would be appreciated.
=20
Cannot decode string with wide characters at
/d00/apps/local/lib/perl5/5.8.8/i686-linux/Encode.pm line 186.
=20
=20
Here is a snippet of the code I have.=20
=20
#! /usr/local/bin/perl
=20
use MIME::Lite;
use Date::Manip;
=20
use Encode;
use Encode::CN;
use Encode::JP;
use Encode::KR;
use Encode::TW;
=20
=20
$sql10=3D"SELECT MSG_TEXT FROM
PTC_MSG_DATA WHERE MSG_ID =3D '515' AND APP_ID =3D '24' AND LANG =3D =
'ko'";
$sth10=3D$dbh_pweb->prepare($sql10);
$sth10->bind_columns (undef,
\$headingsubject); =20
$sth10->execute;
while ($sth10->fetch)
{
Encode::from_to(
$headingsubject, "utf-8","ISO-2022-KR");
}
$sth10->finish;
------_=_NextPart_001_01CA37BA.40224C8A
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" =
xmlns:p=3D"urn:schemas-microsoft-com:office:powerpoint" =
xmlns:a=3D"urn:schemas-microsoft-com:office:access" =
xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" =
xmlns:s=3D"uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" =
xmlns:rs=3D"urn:schemas-microsoft-com:rowset" xmlns:z=3D"#RowsetSchema" =
xmlns:b=3D"urn:schemas-microsoft-com:office:publisher" =
xmlns:ss=3D"urn:schemas-microsoft-com:office:spreadsheet" =
xmlns:c=3D"urn:schemas-microsoft-com:office:component:spreadsheet" =
xmlns:odc=3D"urn:schemas-microsoft-com:office:odc" =
xmlns:oa=3D"urn:schemas-microsoft-com:office:activation" =
xmlns:html=3D"http://www.w3.org/TR/REC-html40" =
xmlns:q=3D"http://schemas.xmlsoap.org/soap/envelope/" =
xmlns:rtc=3D"http://microsoft.com/officenet/conferencing" =
xmlns:D=3D"DAV:" xmlns:Repl=3D"http://schemas.microsoft.com/repl/" =
xmlns:mt=3D"http://schemas.microsoft.com/sharepoint/soap/meetings/" =
xmlns:x2=3D"http://schemas.microsoft.com/office/excel/2003/xml" =
xmlns:ppda=3D"http://www.passport.com/NameSpace.xsd" =
xmlns:ois=3D"http://schemas.microsoft.com/sharepoint/soap/ois/" =
xmlns:dir=3D"http://schemas.microsoft.com/sharepoint/soap/directory/" =
xmlns:ds=3D"http://www.w3.org/2000/09/xmldsig#" =
xmlns:dsp=3D"http://schemas.microsoft.com/sharepoint/dsp" =
xmlns:udc=3D"http://schemas.microsoft.com/data/udc" =
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema" =
xmlns:sub=3D"http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/"=
xmlns:ec=3D"http://www.w3.org/2001/04/xmlenc#" =
xmlns:sp=3D"http://schemas.microsoft.com/sharepoint/" =
xmlns:sps=3D"http://schemas.microsoft.com/sharepoint/soap/" =
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" =
xmlns:udcs=3D"http://schemas.microsoft.com/data/udc/soap" =
xmlns:udcxf=3D"http://schemas.microsoft.com/data/udc/xmlfile" =
xmlns:udcp2p=3D"http://schemas.microsoft.com/data/udc/parttopart" =
xmlns:wf=3D"http://schemas.microsoft.com/sharepoint/soap/workflow/" =
xmlns:dsss=3D"http://schemas.microsoft.com/office/2006/digsig-setup" =
xmlns:dssi=3D"http://schemas.microsoft.com/office/2006/digsig" =
xmlns:mdssi=3D"http://schemas.openxmlformats.org/package/2006/digital-sig=
nature" =
xmlns:mver=3D"http://schemas.openxmlformats.org/markup-compatibility/2006=
" xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns:mrels=3D"http://schemas.openxmlformats.org/package/2006/relationshi=
ps" xmlns:spwp=3D"http://microsoft.com/sharepoint/webpartpages" =
xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/services/2006/types"=
=
xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/services/2006/messag=
es" =
xmlns:pptsl=3D"http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/=
" =
xmlns:spsl=3D"http://microsoft.com/webservices/SharePointPortalServer/Pub=
lishedLinksService" xmlns:Z=3D"urn:schemas-microsoft-com:" =
xmlns:st=3D"" xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal>Hello,<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>We recently moved some Perl applications onto a new =
machine
and one is dying with an encoding error. These previously worked =
fine on
the older machine with older perl encoding modules. What I am =
trying to
do is query an oracle database and pull the string then encode to the =
proper
encoding(based on language). It works for all languages except =
Asian
ones. In the below code I am pulling some Korean text and trying =
to
encode to the Korean charset (this is needed so we can then send the =
text in an
email). When I do this I get the following error. The =
exact
code previously worked before moving to the newer machine. Any =
insight would
be appreciated.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><b>Cannot decode string with wide characters at
/d00/apps/local/lib/perl5/5.8.8/i686-linux/Encode.pm line =
186.<o:p></o:p></b></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Here is a snippet of the code I have. =
<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>#! /usr/local/bin/perl<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>use MIME::Lite;<o:p></o:p></p>
<p class=3DMsoNormal>use Date::Manip;<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>use Encode;<o:p></o:p></p>
<p class=3DMsoNormal>use Encode::CN;<o:p></o:p></p>
<p class=3DMsoNormal>use Encode::JP;<o:p></o:p></p>
<p class=3DMsoNormal>use Encode::KR;<o:p></o:p></p>
<p class=3DMsoNormal>use Encode::TW;<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; =
$sql10=3D"SELECT
MSG_TEXT FROM PTC_MSG_DATA WHERE MSG_ID =3D '515' AND APP_ID =3D '24' =
AND LANG =3D
'ko'";<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; =
$sth10=3D$dbh_pweb->prepare($sql10);<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; =
$sth10->bind_columns
(undef, \$headingsubject); <o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; =
$sth10->execute;<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; while
($sth10->fetch)<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; =
{<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p; Encode::from_to(
$headingsubject, =
"utf-8","ISO-2022-KR");<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; =
&=
nbsp; }<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; &n=
bsp; =
$sth10->finish;<o:p></o:p></p>
</div>
</body>
</html>
------_=_NextPart_001_01CA37BA.40224C8A--