countUtf8Bytes function
Number of bytes message takes when encoded as UTF-8.
Lone surrogates are encoded as U+FFFD (3 bytes), the same as the
JavaScript TextEncoder.
Implementation
int countUtf8Bytes(String message) => utf8.encode(message).length;