Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Character re-map using regex

by zemplen (Novice)
on Nov 16, 2003 at 16:36 UTC ( #307473=perlquestion: print w/ replies, xml ) Need Help??
zemplen has asked for the wisdom of the Perl Monks concerning the following question:

I am working on an application that uses three character sets (Basic Latin, Latin 1 Supplement, Latin Extended and Cyrillic or ISO 8859-1, 2 and 5). Because the data that was given to me was entered using a non-standard fonts, characters have to be mapped to the Unicode standard. Although this re-map works for me I have found a case where it does not and I see no reason for the failure.
use strict; use utf8; ${^WIDE_SYSTEM_CALLS} = 1; no warnings 'utf8'; binmode(STDOUT, ":utf8"); my $text = chr(0x95);# usually a string read in from a file. print ord ($text), "$text\n"; $text=~s/"\x{0095}"/"\x{017E}"/g; print ord ($text), "$text\n";

Comment on Character re-map using regex
Download Code
Re: Character re-map using regex
by shenme (Priest) on Nov 16, 2003 at 16:57 UTC
    The double-quote characters were 'seen' when used inside the s///.   When I changed the statement to:
    $text=~s/\x{0095}/\x{017E}/g;
    your code worked.   Note that if you are displaying the output in a console window it won't look like what you want.   To 'see' the correct output (small cap Z with caron) I had to start up Word, ask for encoded text, then specify UTF-8 coding. (whew)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://307473]
Approved by bart
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-23 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (218 votes), past polls