Flutter base64解码中文乱码

    技术2024-03-09  85

    使用下面的代码获取字符串,中文是乱码

    Uint8List base64deBody = base64Decode(base64enBody); String result = String.fromCharCodes(base64deBody)

    出现乱码的原因是在使用String.fromCharCodes()时,并不能指定编码格式,造成在编码中文出现乱码

    修复:使用utf8编码

    Uint8List base64deBody = base64Decode(base64enBody); String result = Utf8Decoder().convert(base64deBody );

     

    Processed: 0.010, SQL: 9