Hello,
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.
Cannot decode string with wide characters at /d00/apps/local/lib/perl5/5.8.8/i686-linux/Encode.pm line 186.
Here is a snippet of the code I have.
#! /usr/local/bin/perl
use MIME::Lite;
use Date::Manip;
use Encode;
use Encode::CN;
use Encode::JP;
use Encode::KR;
use Encode::TW;
$sql10="SELECT MSG_TEXT FROM PTC_MSG_DATA WHERE MSG_ID = '515' AND APP_ID = '24' AND LANG = 'ko'";
$sth10=$dbh_pweb->prepare($sql10);
$sth10->bind_columns (undef, \$headingsubject);
$sth10->execute;
while ($sth10->fetch)
{
Encode::from_to( $headingsubject, "utf-8","ISO-2022-KR");
}
$sth10->finish;
It looks like some part of the code is missing; I can't see where
$dbh_pweb is created.
> Encode::from_to(
> $headingsubject, "utf-8","ISO-2022-KR");
If it finds wide characters in the $headingsubject, apparently the
database has already decoded it. All you have to do then, is encode it.
from_to combines decoding and encoding in a single function.
$headingsubject = Encode::encode("ISO-2022-KR", $headingsubject);
--
Met vriendelijke groet, Kind regards, Korajn salutojn,
Juerd Waalboer: Perl hacker <#####@juerd.nl> <http://juerd.nl/sig>
Convolution: ICT solutions and consultancy <sa...@convolution.nl>