Do you have some compelling requirement to use Text::Iconv instead of the native Encode module and/or PerlIO encoding layers that come with Perl? Looking at these passages from the Text::Iconv docs, it seems like there are some good reasons to avoid it and use Encode/PerlIO instead:

... Settings of fromcode and tocode and their permitted combinations are implementation-dependent. Valid values are specified in the system documentation [i.e. on each particular system]...

retval() returns the return value of the underlying iconv() function for the last conversion; according to the Single UNIX Specification, this value indicates "the number of non-identical conversions performed." Note, however, that iconv implementations vary widely in the interpretation of this specification...

get_attr(): This method is only available with GNU libiconv, otherwise it throws an exception...

I've had only passing acquaintance with iconv, and that was a few years ago, but based on those passages, it seems that if you decide to use Text::Iconv, you're asking for non-portability. The standard perl Encode module and PerlIO don't seem to have issues of that sort, from what I've seen so far.

(I'm guessing that the problem with iconv might be the presence of several competing implementations -- despite the term "Single UNIX" in its description -- kind of like all the different versions of the "standard" ps utility.)

As for the problem you're having with that code snippet... Why are you converting from utf8 to utf8? Could you try using the script in this node -- tlu -- TransLiterate Unicode -- to look at your code/data, and re-post with the actual unicode codepoint hex values for the characters in question? The character sequences in the OP (when I looked at it) seemed like corrupt data, not interpretable as utf8.

If you don't have a firm, explainable reason why you must use Text::Iconv, I would suggest that you avoid using it. Perhaps tell us more about what processing problem you are trying to solve -- there's bound to be a better way to do it.

(updated to replace unintended "link" with proper square brackets in quoted docs)


In reply to Re: Text::Iconv module usage by graff
in thread Text::Iconv module usage by daptal

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.