I need to convert any non-Ascii characters in a string into their escaped unicode forms (like \u00E3) for use in a program that requires this form. I am using the Unicode::Escape module (specifically the escape function) and it was working out nicely:
$entry[5] = Unicode::Escape::escape($val);
This seemed to work for Latin languages with accents, and Russian (Cyrillic characters) but when I tested it with Japanese characters it gave me the error:
Cannot decode string with wide characters at C:/Perl/lib/Encode.pm line 194.
I'm not sure why I am getting this error, since I'm not trying to decode anything. I'm trying to escape some Japanese characters into escaped Unicode code points.
I think the problem might be because the Escape routine is expecting UTF8 and the Japanese is in UTF16 or something. I'm not entirely sure... The text comes from an excel document which I open with Spreadsheet::Read, and I'm not sure what that is doing with it.
Anyone have any tips on how to figure this one out?
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.