Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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";

Replies are listed 'Best First'.
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:
    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://307473]
Approved by bart
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-02-22 01:28 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.