in reply to Re: unicode normalization layer
in thread unicode normalization layer
I believe
is cheaper thanmy $is_valid = utf8::decode($_);
use Encode qw( decode ); my $is_valid = eval '$_ = decode("utf-8", $_, FB_CROAK); 1';
It's definitely simpler (and you don't even need to load any modules!)
Note that "utf8" is not the same thing "utf-8". "utf8" is the name of Perl's internal encoding. It differs from "utf-8". You definitely want to use "utf-8" when validating (if not always).
I also fixed the bug where decoding the string "0" would be considered a validation error.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: unicode normalization layer
by DrWhy (Chaplain) on Sep 17, 2009 at 05:18 UTC |