如何在Epson TM-T20(USB)上打印繁体汉字
背景: 我正在用C#开发一个POS软件,需要在收据上打印繁体中文字符。
硬件:EPSON TM-T20通过USB连接进行通信
代码:
string text = "鄆";
StringBuilder builder = new StringBuilder();
// Traditional Chinese (big5)
var encoding = Encoding.GetEncoding(950);
// convert the text into a byte array
byte[] source = Encoding.Unicode.GetBytes(text);
// convert that byte array to the new codepage.
byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
// take multi-byte characters and encode them as separate ascii characters
string result = Encoding.GetEncoding("ISO-8859-1").GetString(converted);
// Print
m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|N" + result + "\n");
这是jkealey提供的代码,可在http://blog.lavablast.com/post/2010/01/15/Simplified-Chinese-on-Epson-TM-T88IV-Receipt-Printer.aspx
问题: 在使用jkealey提供的代码之前,打印机打印出“?”而不是汉字,但现在它打印出“ÜP”。
在 Epson TM-T20 实用程序 Ver.1.00 上,我对代码页和国际字符集有以下字体设置。 (我无法发布图像,因为我是新用户)
代码页:PC850(多语言) 国际字符集:中国
我不确定我在哪里出了问题。
Background: I am developing a POS software in C# which requires to print traditional Chinese characters on the receipt.
Hardware: EPSON TM-T20 communicates via USB connection
Code:
string text = "鄆";
StringBuilder builder = new StringBuilder();
// Traditional Chinese (big5)
var encoding = Encoding.GetEncoding(950);
// convert the text into a byte array
byte[] source = Encoding.Unicode.GetBytes(text);
// convert that byte array to the new codepage.
byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
// take multi-byte characters and encode them as separate ascii characters
string result = Encoding.GetEncoding("ISO-8859-1").GetString(converted);
// Print
m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|N" + result + "\n");
This is the code provided by jkealey available at http://blog.lavablast.com/post/2010/01/15/Simplified-Chinese-on-Epson-TM-T88IV-Receipt-Printer.aspx
Problem: Before I use the code provided by jkealey, the printer prints out "?" instead of the Chinese characters, but now it prints out "ÜP".
On the Epson TM-T20 utility Ver.1.00, I have the following font settings for Code-page and International character set. ( I am not able to post an image as I am a new user)
Code-Page: PC850 (Multilingual)
international character set: China
I am not sure where I have gone wrong in this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论