SPVM::Unicode - Unicode Utilities.
The Unicode class of SPVM has methods for Unicode utilities.
use Unicode; my $string = "あいうえお"; my $pos = 0; while ((my $uchar = Unicode->uchar($string, \$pos)) >= 0); # ... }
static method INVALID_UTF8 : int ();
Returns -2.
static method is_unicode_scalar_value : int ($code_point: int);
If the code point $code_point is a Unicode scalar value, returns 1. Otherwise returns 0.
static method uchar : int ($string : string, $offset_ref : int*);
Gets a Unicode codepoint by parsing UTF-8 string $string with the offset $$offset_ref and proceed the offset to the next parsing posision.
If $$offset_ref is over the string length, returns -1.
If an invalid UTF-8 character is found, returns the value of "ERROR_INVALID_UTF8".
static method uchar_to_utf8 : string ($unicode_code_point : int);
Converts the Unicode codepoint $unicode_code_point to a UTF-8 character.
If the $unicode_code_point is invalid Unicode code point, returns undef.
static method utf8_to_utf16 : short[] ($string : string);
Converts the UTF-8 string $string to a UTF-16 string, and returns it.
static method utf16_to_utf8 : string ($string : short[]);
Converts the UTF-16 string $string to a UTF-8 string, and returns it.
static method utf32_to_utf16 : short[] ($string : int[]);
Converts the UTF-32 string $string to a UTF-16 string, and returns it.
static method utf16_to_utf32 : int[] ($string : short[]);
Converts the UTF-16 string $string to a UTF-32 string, and returns it.
Copyright (c) 2023 Yuki Kimoto
MIT License
To install SPVM::Unicode, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM::Unicode
CPAN shell
perl -MCPAN -e shell install SPVM::Unicode
For more information on module installation, please visit the detailed CPAN module installation guide.