Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

replacing hex code characters

7 views
Skip to first unread message

Boudga

unread,
Jul 18, 2003, 12:56:43 PM7/18/03
to
Is it possible to substitute a hex code of "A0" with "20" in a text file
using Perl REGEX?


Brendan Byrd/SineSwiper

unread,
Jul 18, 2003, 12:58:40 PM7/18/03
to
Boudga wrote:

> Is it possible to substitute a hex code of "A0" with "20" in a text file
> using Perl REGEX?

A0 doesn't translate to 20 in decimal, if that's what you mean. If
you're talking about the character that translates into A0, that can be
represented with \xA0, and you can change them with s/\xA0/\x20/g.

Again, you need to be more specific in your posts to get a good answer.

--
Brendan Byrd/SineSwiper <SineS...@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>

Bob Walton

unread,
Jul 20, 2003, 8:10:27 PM7/20/03
to
Boudga wrote:

> Is it possible to substitute a hex code of "A0" with "20" in a text file
> using Perl REGEX?

Yes, but you would be (slightly) better off using the translate operator
if you want to translate characters:

$string=~tr/\240/\040/;

or, if you want to remove the 8th bit from all ASCII characters:

$string=~tr/\200-\377/\000-\177/;

--
Bob Walton

0 new messages