本文介绍了如何在Dart中获取字符串的字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在dart中读取 String 的字节?
在Java中可以通过 String 方法 getBytes()来实现。

How can I read the bytes of a String in dart?in Java it is possible through the String method getBytes().

推荐答案

String foo = 'Hello world';
List<int> bytes = utf8.encode(foo);
print(bytes);



此外,如果要转换回去:

Also, if you want to convert back:

String bar = utf8.decode(bytes);

这篇关于如何在Dart中获取字符串的字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 12:39