leelavenu has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I am trying to find some text and replace with special characters. s/\ζ/\x{03B6}/g; 03B6 is the unicode equivalent value for zeta symbol but it replaces with some other character. can any one help me how to capture unicode values. Thanks in advance. Leela

Replies are listed 'Best First'.
Re: unicode pls help
by ysth (Canon) on Sep 15, 2006 at 08:45 UTC
    Can you show some of your actual code and output? Maybe show the output of:
    $text =~ s/\ζ/\x{03B6}/g; use Data::Dumper; $Data::Dumper::Useqq=1; print Dumper($text);
      This the my script i am editing postscript files and want to search entities and replace with exact special character.

      eg:

      s/\α/a/g; s/\β/ß/g; s/\&zeta1;/\\xce\\xb6/g;
      Pls help me in this.
      system("dir *.ps /b >file.log"); open(in, "file.log"); @files = <in>; close(in); system("del file.log"); foreach $files(@files) { open(inp, $files); $file = "New" . $files; open(out, ">$file"); while(<inp>) { while(/\[\/FitR ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)\]/) { s/\[\/FitR ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)\]/\[\/FitH $2\]/; } s/3B2 Total Publishing System 7\.51d\/W/3B2 Publishing System/g; s/\&alpha;/a/g; s/\&beta;/ß/g; s/\&chi;/chi/g; s/\&delta;/delta/g; s/\&epsi;/epsi/g; s/\&beta;/beta/g; s/\&phi;/phi/g; s/\&gamma;/gamma/g; s/\&eta;/eta/g; s/\&iota;/iota/g; s/\&thetav;/thetav/g; s/\&kappa;/kappa/g; s/\&lambda;/lambda/g; s/\&mu;/mu/g; s/\&nu;/nu/g; s/\&omicr;/omicr/g; s/\&pi;/pi/g; s/\&theta;/theta/g; s/\&rho;/rho/g; s/\&sigma;/sigma/g; s/\&tau;/tau/g; s/\&upsi;/upsi/g; s/\&sigmav;/sigmav/g; s/\&omega;/omega/g; s/\&xi;/xi/g; s/\&psi;/psi/g; s/\&zeta1;/\\xce\\xb6/g; s/\&Delta;/Delta/g; s/\&Phi;/Phi/g; s/\&Gamma;/Gamma/g; s/\&Lambda;/Lambda/g; s/\&Pi;/Pi/g; s/\&Theta;/Theta/g; s/\&Sigma;/Sigma/g; s/\&Upsi;/Upsi/g; s/\&Omega;/Omega/g; s/\&Xi;/Xi/g; s/\&Psi;/Psi/g; s/\&prime;/'/g; s/\&plus;/+/g; s/\&sol;/\//g; s/\&z.urule;/\//g; s/\&ff;/ff/g; s/\[\/Dest \/bib.[0-9][0-9][0-9][0-9] \/Title \(fig\) \/OUT pdfmark//g +; if((/\/OUT pdfmark/) && (/\/Title \((fig|bib|tbl|sec)\)/)) { s/\[\/Dest \/.*? \//\[\/Dest \/unknown \//; } print out $_; } close(inp); close(out); $file =~ s/\n//; $files =~ s/\n//; system("ren $file $files"); }