Skip to main content

str_to_arr

Discworld driver help

str_to_arr

Name

str_to_arr() - Turns a UTF-8-encoded string into an array of char numbers.

Synopsis

int *str_to_arr( string s )

Description

Since a UTF-8-encoded string may use multiple bytes of the string to represent a single character, this efun can be used to convert the string into an array with one number for each character.

The resulting array will terminate with 0.

Example

str = "รถ";
str[0] == 195
str[1] == 182
str_to_arr( str ) == ({ 246, 0 })

See also

arr_to_str, to_utf8, utf8_to