I use Text::Unidecode for this, but I should add that I don't care about fixed width. It's a great module for readability (since it translates e.g. "é" to "e", which I found preferable over replacing every high char with a ?), but I believe it translates e.g. Japanese characters (1 utf char) to for instance "wa"1. This might screw up your alignment.

I know unicode defines several different kinds of spaces (non-breaking or breaking, zero-width, half-width, em- and en- spaces just to name some off the top of my head). It's entirely possible that the utf8 2 ascii translation misses one of these.
Depending on the input, you might try a simple regexp like  s/\s/ /g before translating to ascii, although I don't know exactly which unicode whitespace characters are defined within \s.
_______________________
1 I'm not at all familiar with Japanese. Just mentioned it for illustrative purposes. The Text::Unidecode pod has more detailed (and more accurate!) examples.


In reply to Re: UTF-8 Decoding, Wide Characters, and XML::Twig by rhesa
in thread UTF-8 Decoding, Wide Characters, and XML::Twig by thedoe

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.