admin管理员组文章数量:1123150
I'm facing an issue while trying to print the Euro symbol (€) on my thermal receipt using a Bluetooth thermal printer and the /documentation/bluetooth_print/latest/ package in Flutter.
What I’m using: Flutter package: bluetooth_print Printer type: Thermal Bluetooth printer Encoding: I’ve tried using ISO-8859-15 (Latin-9) to include the Euro (€) symbol. The Problem: Whenever I print a line containing the Euro symbol (€), the printer outputs strange characters (for example, a 1 or a garbled symbol). Below is a sample of my current code:
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,
));
What I’ve Tried So Far: Using UTF-8 Encoding: I tried:
utf8.encode('Total price: 20.00 €');
Result: The Euro symbol (€) is still displayed incorrectly.
Using Unicode Escape Code (\u20AC): I tried:
'Total price: 20.00 \u20AC';
Result: The output is still incorrect.
Replaced Euro Symbol with Alternative Text: I replaced € with "EUR", which worked fine, but it’s not ideal.
Tested with Another Thermal Printer: I tested another printer, but the problem persists.
Here a image:
版权声明:本文标题:Unable to print the Euro € symbol on a receipt using the Flutter bluetooth_print package - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736552699a1944533.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论