转换List< int>放入Dart中的弦? [英] Convert a List<int> into a String in Dart?

查看:95
本文介绍了转换List< int>放入Dart中的弦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一个文件,并给自己定了一个整数列表。对于我的大部分工作,这是我想要的,但是在一种情况下,我还需要将某些 List< int> 转换为 String

I have read a file and got myself a list of integers. For most of my work this is what I want to get, but in one case I also need to convert some of List<int> into a String.

要指定得更详细些,我想将字符串编码为UTF-8。

To be more specified, I want to encode the string in UTF-8.

这是我刚刚尝试过的:

var decoder = new Utf8Decoder(figures);
print(decoder.decodeRest());

但是我得到的只是一个整数列表。

But all I get is a list of integers.

推荐答案

String.fromCharCodes(List< int> charCodes)可能正是您正在寻找的东西。

String.fromCharCodes(List<int> charCodes) is probably what you're looking for.

  List<int> charCodes = const [97, 98, 99, 100];
  print(new String.fromCharCodes(charCodes));

这篇关于转换List&lt; int&gt;放入Dart中的弦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆