You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Flutter bluetooth_print包打印欧元符号€失败问题咨询

蓝牙热敏打印机无法正常打印欧元符号(€)的问题排查与解决请求

使用Flutter的bluetooth_print包连接蓝牙热敏打印机打印收据时,欧元符号(€)无法正常输出,显示乱码或奇怪字符(如数字1)。

环境信息

  • Flutter包:bluetooth_print
  • 打印机类型:蓝牙热敏打印机
  • 编码尝试:已尝试ISO-8859-15(Latin-9)编码支持欧元符号

当前代码示例

List<int> encodeToLatin9(String input) {
  const latin9Table = {
    '€': 0xA4, // Euro sign in ISO-8859-15
  };

  List<int> encodedBytes = [];
  for (var char in input.runes) {
    if (char < 128) {
      encodedBytes.add(char);
    } else if (latin9Table.containsKey(String.fromCharCode(char))) {
      encodedBytes.add(latin9Table[String.fromCharCode(char)]!);
    } else {
      encodedBytes.add(0x3F); // Replace with '?' if character not found
    }
  }
  return encodedBytes;
}

List<LineText> list = [];
list.add(LineText(
  type: LineText.TYPE_TEXT,
  content: String.fromCharCodes(encodeToLatin9('Total price: 20.00 €')),
  align: LineText.ALIGN_CENTER,
));

已尝试的解决方法

  • 使用UTF-8编码:

    utf8.encode('Total price: 20.00 €');
    

    结果:欧元符号仍显示错误。

  • 使用Unicode转义码:

    'Total price: 20.00 \u20AC';
    

    结果:输出仍不正确。

  • 替换欧元符号为文本“EUR”:此方法可行,但并非理想方案。

  • 更换另一台热敏打印机测试:问题依旧存在。

打印异常效果

打印异常截图

现寻求有效的解决方案,以实现欧元符号的正常打印。

内容的提问来源于stack exchange,提问作者Asile34

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 02:32:03