encode static method
Encodes the given value
string into a list of bytes using the specified type
.
The type
parameter determines the encoding type to use, with UTF-8 being the default.
Returns a list of bytes representing the encoded string.
Example:
List<int> encodedBytes = StringUtils.encode("Hello, World!");
Implementation
static List<int> encode(String value,
[StringEncoding type = StringEncoding.utf8]) {
switch (type) {
case StringEncoding.utf8:
return utf8.encode(value);
case StringEncoding.base64:
return base64Decode(value);
default:
return ascii.encode(value);
}
}