Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
From experience I can tell you that not every CPAN module is capable of properly handling the Asian languages, especially Chinese, Japanese, and Korean (CJK). I would guess, in fact, that the majority of them are not compatible with these languages. I have frequently had to write my own code to deal with them because of this.

Here are some tips on ways to deal with everything in UTF8:

use Encode; use Encode qw(encode decode); binmode STDOUT, ':utf8'; print "Content-type: text/html; charset=utf-8\n\n"; open SOURCE, '<:encoding(utf8)',$sourcefile or die "Cannot open source! $!\n"; open (TARGET, ">:encoding(utf8)", "$targetfile") or die "Cannot open target file! $!\n"; print TARGET <<HTML; <html lang="utf8"> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf8"> ... <form name="myform" method="POST" accept-encoding="UTF-8" accept-chars +et="utf-8" action="$thisprogram"> ... HTML foreach $line (@source) { $line = decode("utf-8", $line);

Note that you may not need to do all of these at once. For example, if you already read the file in as UTF8, there is no need to decode each line of the file as UTF8 again. However, redundancy should have no side effects other than adding a little more bulk to your code.

Blessings,

~ Polyglot ~


In reply to Re: Handling Traditional Chinese Characters by Polyglot
in thread Handling Traditional Chinese Characters by dhinesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (14)
    As of 2014-08-27 20:09 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (252 votes), past polls