<?xml version="1.0" encoding="windows-1252"?>
<node id="822187" title="Re: Regexp with unicode problem" created="2010-02-09 08:08:09" updated="2010-02-09 08:08:09">
<type id="11">
note</type>
<author id="644375">
Polyglot</author>
<data>
<field name="doctext">
As others have explained to me here previously, if you use unicode characters in your code, then you need to specify that in your uses.  For example, if you are using utf8 characters within your code, you should specify "use utf8;".  However, you do not need to make this declaration for characters that your code will act &lt;i&gt;upon&lt;/i&gt;, only for those utf8 characters that are in the code itself.
&lt;p&gt;
For characters outside your code, you may wish to make sure that they are recognized as utf8 by perl.  The following examples present some ways of doing this--though you should not need to use them all at once.  These are all lines which I have used at one time or another to deal with utf8.
&lt;code&gt;
#FOR WORKING WITH UTF8, AS NECESSARY WITH CJK
use Encode;

#PARTICULARLY NEED THE ENCODE/DECODE FUNCTIONS
use Encode qw(encode decode);			

#TO MAKE THE DEFAULT STANDARD ENCODING BE UTF8
use open qw( :std :encoding(UTF-8) );	

#LIKE print CGI::header(); FOR UTF8 OUTPUT TO HTML
print "Content-type: text/html; charset=utf-8\n\n";  

#SET DEFAULT I/O TO UTF8
binmode STDOUT, ":utf8";

#OPEN/READ A UTF8 FILE
open (DAT, '&lt;:encoding(utf8)', $Data) or die "Can't open file! $!\n";
$source = &lt;DAT&gt;;
close DAT;
&lt;/code&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-644375"&gt;
&lt;p&gt;Blessings,
&lt;p&gt;&lt;i&gt;~Polyglot~&lt;/i&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
822000</field>
<field name="parent_node">
822000</field>
</data>
</node>
