Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^4: Replacing non ascii in string

by IanD (Initiate)
on Jan 31, 2013 at 05:21 UTC ( #1016210=note: print w/replies, xml ) Need Help??

in reply to Re^3: Replacing non ascii in string
in thread Replacing non ascii in string

I have solved by adding another line

$url = ""; $data_string = get($url); $data_string =~ tr/‘’/'/; $data_string =~ tr/’/'/; $data_string =~ s/'''/'/g;

For some reason when I view the source of that xml I see the apostrophes that I show here. However to check it I was doing the following:

$file1 = "aafc.txt"; open (FILE,">$file1"); print FILE $data_string; close(FILE);

Here I was seeing the string as
’Powder Capital’ instead of ‘Powder Capital’ as in the source of the xml. I don't understand why, clearly there has been some type of conversion of character types on reading the file. By making the substitution for ’ instead of ‘ it worked but then produced 3 ''' instead. So by doing that string replacement it worked. Seems bizarre to me but it works!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016210]
[Discipulus]: DBI::CSV + utf8 = BOO?M
[erix]: in extremis we tend to forget stuff ;)
[ELISHEVA]: \Disciplus : lol
[Discipulus]: and ELISHEVA we waait one your post since ~2years... ;=)
[ELISHEVA]: has it really been that long?
[Discipulus]: it seems..
[Discipulus]: more: just one thread in the last ~5 years
[Discipulus]: but Dumas is waiting for me in the bed.. luckly as book author.. see you!
[ELISHEVA]: Sleep well!
[ELISHEVA]: Or read well

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2017-05-28 20:45 GMT
Find Nodes?
    Voting Booth?