[tpm] Perl and Unicode [do not read this from a terminal]

Liam R E Quin liam at holoweb.net
Fri May 1 14:21:25 PDT 2009


On Fri, 2009-05-01 at 16:43 -0400, Antonio Sun wrote:
> Thanks a lot for clarification, Abram.
> 
> BTW, 
> 
> Anyone knows how to split an Unicode string into individual characters
> with Perl? E.g., from "骆驼" to '骆' & '驼'?

#! /usr/bin/perl -w
use strict;

use utf8;
binmode(STDOUT, ":utf8");

my $input = "骆驼";

print join("<->", split(//, $input)), "\n";

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org



More information about the toronto-pm mailing list