unicode - How to replace characters in a file utf8 in perl? -


i have (it works):

perl -c -mtext::unidecode -n -i -e'print unidecode( $_)' unicode_text.txt 

and want same in script:

#!/usr/bin/perl -w -csa  use utf8; use text::unidecode;   while(<>) {     print unidecode($_); } 

but doesn't work.

you should have got error message

too late "-csa" option 

which makes program read input file utf-8-encoded.

instead need put

use open qw( :std :utf8 ); 

before while loop, same -cs on command line, i.e. set stdin, stdout , stderr handles utf-8 encoding


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -