Question on conversion from UTF8 to Shift_JIS (or ISO-2022-JP)

W

wing328hk

Hi,

Sorry this is a cross-post in Perl.Unicode.

I've some questions about converting Japanese from UTF8 to Shift_JIS
(or finally ISO_2022_JP) under Unix as follows:

UTF8 ==> Shift_JIS ==> ISO-2022-JP

The first conversion from UTF8 to Shift_JIS is done using Text::Iconv.
The second conversion from Shift_JIS to ISO-2022-JP is done using
mathematic algorithm.

However, I found that some Japanese characters are corrupted during the
first conversion (UTF8 ==> Shift_JIS). For example, the Japanese
character (or symbol) ~ can be found in Shift_JIS but it was
converted to ? after the first conversion.

Does any one know a perfect (or better) way to convert from UTF8 to
Shift_JIS (or ISO-2022-JP)?

I know that ISO-2022-JP is a subset of Unicode but I couldn't find a
perfect way to convert from UTF8 to ISO-2022-JP and that's why others
suggest me to first convert from UTF8 to Shift_JIS and then from
Shift_JIS to ISO_2022_JP mathematically. Your comment is highly
aprpeciated.

Thanks,
Wing
 
P

Peter J. Holzer

I've some questions about converting Japanese from UTF8 to Shift_JIS
(or finally ISO_2022_JP) under Unix as follows:

UTF8 ==> Shift_JIS ==> ISO-2022-JP

The first conversion from UTF8 to Shift_JIS is done using Text::Iconv.
The second conversion from Shift_JIS to ISO-2022-JP is done using
mathematic algorithm.
[Some characters aren't converted correctly]

Have you tried Encode?

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top