Re: how to convert the characters ASCII(0-255) to ASCII(0-127)
- From: Samwyse <samwyse@xxxxxxxxx>
- Date: Thu, 29 Dec 2005 18:35:58 GMT
Alextophi wrote:
EXAMPLE:
the log "C:\WINDOWS\SchedLgU.Txt", contains wide ASCII characters (ex: "tâche" or "système"),
$LINE = ~ tr/\x8A/\x65 /; # remplace ... è > e $LINE = ~ tr/\x83/\x61 /; # remplace ... â > a
- how to replace all the ASCII characters?
Are they wide ASCII, or extended ASCII? Your example (and your subject line) are talking about extended, not wide, characters. BTW, your code fragment can be shorted to this:
$LINE = ~ tr/\x8A\x83/\x65\x61/;
What you want to do is a lossy transformation, so I doubt that there's any one "right" way to do it. From your example, I'd use this page:
http://www.cplusplus.com/doc/papers/ascii.html
and hand-build a 'tr' that does what you want. \xC0 through \xFF are fairly easy, the fun part is deciding what you want to do with "copyright" and "registered". If you'll be translating characters into strings ("copyright" into "(C)" and/or HTML entities) then you want a substitution table:
my %xlate = (
"\xA9" -> "(C)",
"\xAE" -> "(R)",
"\xB1" -> "+/-",
# add more lines as desired
);
my $from = join('', keys %xlate);
# ...
$input =~ s/([$from])/$xlate{$1}/ego;
.- Follow-Ups:
- Re: how to convert the characters ASCII(0-255) to ASCII(0-127)
- From: Alan J. Flavell
- Re: how to convert the characters ASCII(0-255) to ASCII(0-127)
- References:
- [FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127)
- From: Alextophi
- Re: [FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127)
- From: Paul Lalli
- Re: how to convert the characters ASCII(0-255) to ASCII(0-127)
- From: Alextophi
- [FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127)
- Prev by Date: Re: Ordering string of commands in a file
- Next by Date: Re: Is any diffrence in...?
- Previous by thread: Re: how to convert the characters ASCII(0-255) to ASCII(0-127)
- Next by thread: Re: how to convert the characters ASCII(0-255) to ASCII(0-127)
- Index(es):
Relevant Pages
|