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?
For Dart >1.0 this is now done with the convert library.
import 'dart:convert'; List<int> bytes = utf8.encode("Some data"); print(bytes) //[115, 111, 109, 101, 32, 100, 97, 116, 97]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With