我正在尝试开发一个应用程序,以使用dart语言将文本转换为二进制(反之亦然)。这将是我第一个扑扑的应用程序。 我发现dart:convert库可以做到这一点 ,但我仍然不知道如何使它工作。可以使用一些帮助。谢谢!
示例:https://www.rapidtables.com/convert/number/ascii-to-binary.html
答案 0 :(得分:0)
https://api.flutter.dev/flutter/dart-core/String/codeUnits.html 请使用它。
或
https://pub.dev/packages/binary_codec库也将为您提供帮助 您可以像这样使用它:
/// Encode the generated data
Uint8List encoded = binaryCodec.encode(exampleObject);
/// Decode the encoded data
var decoded = binaryCodec.decode(encoded);
/// Check if they are the same
if (exampleObject.toString() == decoded.toString()) {
/// They should be the same
print('Success');
} else {
/// Else theres a bug in the library
/// Please send the [exampleObject] that leads here and on which
/// platform you are to the author of this library (stefan.zemljic@gmx.ch)
print('Wait... What???');
}