Name

SPVM::Encode - Encode/Decode Strings

Description

The Encode class in SPVM has methods to encode/docode strings.

Usage

use Encode;

my $string = "あいうえお";

my $utf16_string = Encode->encode_utf16($string);

my $string_again = Encode->decode_utf16($utf16_string);

Class Methods

decode_utf8

static method decode_utf8 : string ($utf8_string : short[]);

Normalizes the UTF-8 string $utf8_string to NFC, and returns it.

encode_utf8

static method encode_utf8 : short[] ($string : string);

Copies the UTF-8 string $string and returns it.

decode_utf16

static method decode_utf16 : string ($utf16_string : short[]);

Converts the UTF-16 string $utf16_string to a UTF-8 string, and returns it.

encode_utf16

static method encode_utf16 : short[] ($string : string);

Converts the UTF-8 string $string to a UTF-16 string, and returns it.

decode_utf32

static method decode_utf32 : string ($utf32_string : int[]);

Converts the UTF-32 string(Unicode code points) $utf32_string to a UTF-8 string, and returns it.

encode_utf32

static method encode_utf32 : int[] ($string : string);

Converts the UTF-8 string $string to a UTF-32 string(Unicode code points), and returns it.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License