How do I convert a UTF-8 String into an array of bytes in Dart?

dart

Solution

You need to import dart:utf and use its encodeUtf8 function. There is actually a existing redis client for Dart here which makes use of these functions.

Problem

I'm creating a Redis client and would like to create a byte array for sending to the Redis server. To issue commands to the server, I need to convert Dart's UTF-8 strings into a bytes which can be written to a socket. How can I do this?

Original source

Related problems