Converts a string into an array of UTF-8 encoded byte values.
This function iterates over each character in the input string and encodes it as one or more bytes
according to the UTF-8 encoding standard. It correctly handles surrogate pairs for characters outside
the Basic Multilingual Plane (BMP).
Parameters
str: string
The input string to encode as UTF-8 bytes.
Returns number[]
An array of numbers, each representing a byte in the UTF-8 encoding of the input string.
Converts a string into an array of UTF-8 encoded byte values.
This function iterates over each character in the input string and encodes it as one or more bytes according to the UTF-8 encoding standard. It correctly handles surrogate pairs for characters outside the Basic Multilingual Plane (BMP).