Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Uint8List to String with Dart

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 Uint8List.

    var cipherText = cipher.process( inputAsUint8List );             return ASCII.decode(cipherText); 

ASCII.decode throws an error since some of the integers are > 127.

like image 810
Manuel Riviere Avatar asked Feb 17 '15 15:02

Manuel Riviere


1 Answers

I guess this should do it:

String s = new String.fromCharCodes(inputAsUint8List); var outputAsUint8List = new Uint8List.fromList(s.codeUnits); 
like image 56
Günter Zöchbauer Avatar answered Sep 21 '22 14:09

Günter Zöchbauer