Well, the hard part is that it's not one char to one char. The simplest (and portable) way would be to just have a list of all the translations and do each one to the string. BUT, as others have pointed out, that might lead to problems if the output of one matches the input of another. So careful ordering of the individual replacements might fix that, and if there is a circular one somewhere then introduce a dummy code as an intermediate.

You can also try running the whole set at one position at a time, rather than running each translation over all positions. Without using fancy stuff like /G and setting the string's current scan postion, you can use a dummy char. For example, use * but in real life use something that is not a legal char. Start by prepending * to the string. Then your chain of replacements will be something like "*A/" to "Á*", that is, it moves the star to the next position when one is found. The last one moves it without changing the one character, and you stop when you find one that works and start over, repeating until the * is at the end.

I would suggest, regardless, that you use numeric codes instead of visible chars in the wrong character set in the source file.


In reply to Re: Orthography Translation using Regex by John M. Dlugosz
in thread Orthography Translation using Regex by Baz

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.