|Welcome to the Monastery|
Search & replace of UTF-8 characters ?by levien (Initiate)
|on Feb 25, 2010 at 16:25 UTC||Need Help??|
levien has asked for the
wisdom of the Perl Monks concerning the following question:
I would like to request the wisdom of the Monks on the hairy subject of UTF-8...
To fix some problems with BibTeX and UTF-8 characters, I've made a little perl-script that (among other things) should replace some UTF-8 characters by TeX-macros. The problems is that I cannot seem to get the regular expressions to recognise UTF-8 characters.
I use something like:
It run this in Perl 5.10.0 on a 64-bit Ubuntu Jaunty system. The locale is set to en_US.UTF-8, and I checked that the input-file is really UTF-8.
When I run the script however, it seems to replace only the 8-bit ASCII characters 0xa5 and 0xc5 (resulting in invalid UTF-8 output), instead of replacing the UTF-8 ones as I intended. I tried adding "use utf8", "-CIO" and/or setting STDIN and STDOUT to ":utf8" using binmode, but it doesn't seem to make a difference.
I'm a bit stuck now, does anyone know what I'm doing wrong?Best regards, Levien