Hi there,
You posted that to the krakow.pm mailing list and I answered you there - did you not receive my email? Maybe the list server is not working correctly. Anyway here is the example that I typed for you:
use utf8;
binmode(STDOUT, ":utf8");
my $string = "azsc";
while( $string =~ /(\w)/g ){
print $1;
}
print "\n";
__OUTPUT__
azsc
Replace the 'azsc' with utf8 encoded characters - and it should work, unfortunately PerlMonks mangles the characters when I try to input them here.
This does not depend on the locale - but instead it is using the character semantic, it think this is the more modern approach. The important point is that your data needs to be correctly decoded into the characters. Here I used the utf8 pragma so I could put the characters into the program text, but if you read the data from outside sources you need to decode it - this is covered in multiple online sources for example:
open(my $fh, "<:encoding(UTF-8)", "filename")
|| die "can't open UTF-8 encoded filename: $!";
this snipped is part of the documentation for the 'open' Perl function.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|