Text is Unicode
A string in Novis is always valid UTF-8 text. Its methods work on graphemes (what a person counts as
one character). bytes is a different type, for binary data:
<?nvs// This program counts and reverses text that has accents and an emoji.string $word = 'café 👍🏽';
// `Core\Str::length` counts the characters a person sees. This prints `6`.echo Core\Str::length($word), "\n";
// `Core\Str::reverse` keeps each character whole.echo Core\Str::reverse($word), "\n";
// `bytes` is binary data. Its length is the number of bytes.echo Core\Bytes::length($word as bytes), "\n";6👍🏽 éfac14The text has six characters. The emoji with a skin tone is one character. In Unicode it is two code points (two numbers).
Core\Str::reverse keeps every character whole. There is no second set of methods for
multi-byte text, and no method takes an encoding argument.
Read more in Syntax: strings and
Reference: Core\Str.
