Convert Uint8List to String with Dart

后端 未结 4 1852

cipher.process returns an Uint8List which is a list of unsigned integers (0-255). I need to convert this Uint8List to a string that I can easily convert back to the same Uin

4条回答
  •  鱼传尺愫
    2021-01-07 19:02

    Dart uses UTF-16 to store Strings. For now in Dart there is no simple way of converting it easly to bytes and backwards. Therefore, you can use raw calculations to convert String to Uint8List and backwards.

    Dart code:

    import 'dart:typed_data';
    
    void main() {
      // Source
      String source = 'Hello! Cześć! 你好! ご挨拶!Привет! ℌ

提交回复
热议问题