This script connects to MSSQL database, reads data and populates it in a pop-up window. Everything is working fine except that the special characters (like chinese/japanese language characters) are NOT getting displayed properly (?? are getting displayed instead). In other words, the encoding is getting lost.
The special characters in the database looks fine. The html pop-up window are UTF-8 encoded. So, its the perl script thats causing the issue.
Thanks in advance!!
@items have the data from the database.
my $count=0;
foreach my $row (@items)
{
my $id = @$row[0];
my $name = @$row[1];
$logger->debug("INITIAL ID: $id");
$logger->debug("INITIAL Name: $name");
eval {Encode::from_to($name, 'utf-16le', 'utf-8', Encode::FB_CROA
+K);};
#eval {Encode::from_to($name, 'ucs-2', 'utf-8', Encode::FB_CROAK)
+;};
if ($@) {
my $error_message = qq(Can Not Encode to UTF-8: $@);
$logger->debug("$error_message"); # Log out $error_messag
+e
}
print <<"END";
$name
END
$count=$count+1;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.