arrays – 使用Dart将Uint8List转换为String
发布时间:2020-12-14 02:14:03 所属栏目:Windows 来源:网络整理
导读:cipher.process返回Uint8List,它是无符号整数列表(0-255).我需要将此Uint8List转换为一个字符串,我可以轻松地将其转换回相同的Uint8List. var cipherText = cipher.process( inputAsUint8List ); return ASCII.decode(cipherText); ASCII.decode抛出一个错误
cipher.process返回Uint8List,它是无符号整数列表(0-255).我需要将此Uint8List转换为一个字符串,我可以轻松地将其转换回相同的Uint8List.
var cipherText = cipher.process( inputAsUint8List ); return ASCII.decode(cipherText); ASCII.decode抛出一个错误,因为一些整数是> 127. 解决方法
我想这应该这样做:
String s = new String.fromCharCodes(inputAsUint8List); var outputAsUint8List = new Uint8List.fromList(s.codeUnits); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |