Perhaps I wasn't clear - you have to do that only once - then you know the mapping, assuming that it stays constant. Once you have that mapping, it's trivial to re-implement in perl.
You should also check if there are additional rules (like collapsing multiple non-printable characters into one, or something like that).