I have some image files which have unicode caption.

Unicode is not a character encoding. If ExifTool doesn't decode the strings for you, you have to do it yourself. And you have to know its encoding first. There's no way around that.

However, I don't know how to output them to HTML file in their native encoding.

In which "native encoding"? That of the HTML files? which encoding is that?

Let me get this straight: When you want to change the encoding of something, Encode (or the IO layers) are they way to go, but you have to know both the source and destination encoding.

Also make sure to always test with reliable tools and as soon as possible. hexdump in conjunction with an encoding table is reliable. Browsers (that often try to guess an encoding, and sometimes fail) are not.


In reply to Re: How to encode for non-unicode output by moritz
in thread How to encode for non-unicode output by cheerful

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.