Sorry for hijacking your thread, graff, but I think the problem lies in the inner workings of Jcode's getcode() function, which fails to identify UCS-2 under certain circumstances. An example:

my $a = "\x{3042}"; # Hiragana 'a' show_info($a); # UTF-8 my $a_cp932 = encode("cp932", $a); show_info($a_cp932); my $a_ucs2le = encode("ucs2le", $a); show_info($a_ucs2le); my $a_ucs2be = encode("ucs2be", $a); show_info($a_ucs2be); sub show_info { my $s = shift; my $hex = unpack("H*", $s); my $enc = getcode($s); print "hex = $hex\n"; print "enc = $enc\n\n"; }

This prints (comments added)

hex = e38182 enc = utf8 # OK hex = 82a0 enc = sjis # OK hex = 4230 enc = ascii # wrong hex = 3042 enc = ascii # wrong

As we can see, the latter two UCS-2 strings are incorrectly identified as "ascii"...

Well, if you think about it, how should the function's heuristics tell apart the single-char UCS-2 strings from their regular two-char ASCII interpretations (i.e. "0B" == "\x30\x42" or "B0" == "\x42\x30")?

Personally, I'd just look at the raw byte sequences. Sometimes, "less is more" ;)


In reply to Re^5: MS Access Input -> Japanese Output by almut
in thread MS Access Input -> Japanese Output by Zettai

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!
  • 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:
    & &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.