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

Discussion in 'Perl Misc' started by wing328hk@gmail.com, Apr 19, 2006.

  1. Guest

    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
     
    , Apr 19, 2006
    #1
    1. Advertising

  2. wrote:
    > 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

    --
    _ | Peter J. Holzer | Man könnte sich [die Diskussion] auch
    |_|_) | Sysadmin WSR/LUGA | sparen, wenn man sie sich einfach sparen
    | | | | würde.
    __/ | http://www.hjp.at/ | -- Ralph Angenendt in dang 2006-04-15
     
    Peter J. Holzer, Apr 22, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kettle
    Replies:
    4
    Views:
    486
    kettle
    Oct 24, 2007
  2. Kev Jackson

    Shift_jis encoding issue?

    Kev Jackson, Mar 27, 2006, in forum: Ruby
    Replies:
    1
    Views:
    111
    Kev Jackson
    Mar 27, 2006
  3. Mikel Lindsaar
    Replies:
    0
    Views:
    491
    Mikel Lindsaar
    Mar 31, 2008
  4. Replies:
    5
    Views:
    565
    John W. Kennedy
    Mar 18, 2006
  5. Replies:
    0
    Views:
    87
Loading...

Share This Page