for perl wizards.
m.seaman at infracaninophile.co.uk
Fri Oct 9 09:28:32 UTC 2009
Gary Kline wrote:
> Whenever I save a wordpeocessoe file [OOo, say] into a
> text file, I get a slew of hex codes to indicate the char to be
> used. I'm looking for a perl one-liner or script to translate
> hex back into ', ", -- [that's a dash), and so forth. Why does
> this fail to trans the hex code to an apostrophe?
> perl -pi.bak -e 's/\xe2\x80\x99/'/g'
> If there any another other tools, I'm interested!
That's a problem with shell quoting rather than perl. You're using '
as the delimiter on your command line, so you need to escape any instances
within commands. Or you can replace a literal ' with the ASCII character
However, in the more general sense what you are doing is replacing certain
UTF-8 character codes with similar characters from the ASCII range. That
sounds to me like a job for iconv(1) -- in ports as converters/libiconv
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20091009/768c1f62/signature.pgp
More information about the freebsd-questions