none
The Microsoft POS Tester(PointOfService) ——Simplified Chinese was printed garbled RRS feed

  • 问题

  • Now. 

    First ,I set the CharacterSet == 936(Chinese Simplified (GB2312)),

    Then,I input some text for “谢谢大家帮忙”. when I click the button of Print Normal ,the Receipt shows some normal English and Chinese Garbled 。

     

    THE CODE 

     private void PrintButton_Click(object sender, System.EventArgs e)
            {
                try
                {
                    // replace ESC with Char(27) and add a CRLF to the end
                    //string text = TextToPrint.Text.Replace("ESC", ((char)27).ToString()) + "\x1B|1lF";
                    StringBuilder builder = new StringBuilder();
                    string text = TextToPrint.Text;
                    _printer.PrintNormal(CurrentStation, text + "\n");
                }
                catch (Exception ae)
                {
                    ShowException(ae);
                }
            }
    

     

    谢谢大家!

     

    Rwecho

    2011年12月8日 9:05

答案

  • You need the special multilingual version (which we have: TM-T88IVM). Second, you need to ensure that Epson OPOS sees it configured as the multilingual version, otherwise it won’t know it can print in simplified Chinese.

    这段的意思是说必须是多种语言版本的打印机,我对这个产品系列不了解,不清楚你的打印机是否是多语言支持的版本。

    此外,看这段:

     

    converting this byte array back to a string and sending it to the printer did not work. It did not work because I was simply reconverting it back into a Unicode string (C#). I also did not have a PrintNormal method I could call that would accept a byte array. I therefore computed the decimal value of {145, 6} (256 * 145 + 6 = 37126) and looked it up to see it was indeed the character I was looking for ()!  I therefore implemented an ugly byte-by-byte conversionand sent it off to the printer. It worked!

       1:  StringBuilder builder = new StringBuilder();
       2:   
       3:  // simplified chinese
       4:  var encoding = Encoding.GetEncoding(936);
       5:   
       6:  // convert the text into a byte array
       7:  byte[] source = Encoding.Unicode.GetBytes(text);
       8:   
       9:  // convert that byte array to the new codepage. 
      10:  byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
      11:   
      12:  // take multi-byte characters and encode them as separate ascii characters 
      13:  foreach (byte b in converted)
      14:      builder.Append((char)b);
      15:   
      16:  // return the result
      17:  string result = builder.ToString();

     

    页面编码转成936后,不能简单的转化为unicode然后打印,那样还是打印不出汉字,需要一个字节一个字节的添加到打印字符串中,这样文章作者是可以打印出汉字了。

    那么我建议你首先确认打印机是否是多语言支持的,然后用上面这段代码打印汉字。



    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    • 已标记为答案 Paul Zhou 2011年12月19日 7:54
    2011年12月13日 7:28

全部回复

  • 你好,

    你可以看看这篇博文:

    http://blog.lavablast.com/post/2010/01/15/Simplified-Chinese-on-Epson-TM-T88IV-Receipt-Printer.aspx

    代码稍做修改:

     

     string text = TextToPrint.Text;

               
    StringBuilder builder = new StringBuilder();

               
    var encoding = Encoding.GetEncoding(936);

               
    // 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, result + "\n");

     


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us

    2011年12月9日 5:42
  • 哈哈,你是用中文回答的啊,

     

    Hi,Paul Zhou

    我看了那篇文章,不过我的打印机的型号是 EPSON TM-T88IV,看那篇文章说:

    The first thing to note is that you cannot use any plain old Epson TM-T88IV to print Chinese characters. You need the special multilingual version (which we have: TM-T88IVM).

    那是不是我这个机器就无法打印 汉字呢?

    可是我不通过 OPOS 进行打印,而另一种方式:装打印机驱动——PrintDocument 类进行打印,这种情况是可以打印出汉字的。

     

    我是不是可以理解

    PrintDocument 类用的字库是 操作系统的?

    而OPOS 用的字库是 机器自带的,这样是不是没办法了——问题还没解决,看了你说的那篇文章依然没解决(OPOS)?

    可是,这台打印机上面写的是 made in china。。。。。。。。。。

    2011年12月13日 4:46
  • 另外,这台机器的默认CharacterSetList  如下,我挨个试了,并不能打出正确的汉字,通过你上面提到的编码转换也不行,因为这里面根本没有936,另外强制添加上936也是不行得,我怀疑机器内部字库没有936

        [0]: 255

        [1]: 437

        [2]: 850

        [3]: 852

        [4]: 858

        [5]: 860

        [6]: 863

        [7]: 865

        [8]: 866

        [9]: 999

        [10]: 1252

    2011年12月13日 4:49
  • You need the special multilingual version (which we have: TM-T88IVM). Second, you need to ensure that Epson OPOS sees it configured as the multilingual version, otherwise it won’t know it can print in simplified Chinese.

    这段的意思是说必须是多种语言版本的打印机,我对这个产品系列不了解,不清楚你的打印机是否是多语言支持的版本。

    此外,看这段:

     

    converting this byte array back to a string and sending it to the printer did not work. It did not work because I was simply reconverting it back into a Unicode string (C#). I also did not have a PrintNormal method I could call that would accept a byte array. I therefore computed the decimal value of {145, 6} (256 * 145 + 6 = 37126) and looked it up to see it was indeed the character I was looking for ()!  I therefore implemented an ugly byte-by-byte conversionand sent it off to the printer. It worked!

       1:  StringBuilder builder = new StringBuilder();
       2:   
       3:  // simplified chinese
       4:  var encoding = Encoding.GetEncoding(936);
       5:   
       6:  // convert the text into a byte array
       7:  byte[] source = Encoding.Unicode.GetBytes(text);
       8:   
       9:  // convert that byte array to the new codepage. 
      10:  byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
      11:   
      12:  // take multi-byte characters and encode them as separate ascii characters 
      13:  foreach (byte b in converted)
      14:      builder.Append((char)b);
      15:   
      16:  // return the result
      17:  string result = builder.ToString();

     

    页面编码转成936后,不能简单的转化为unicode然后打印,那样还是打印不出汉字,需要一个字节一个字节的添加到打印字符串中,这样文章作者是可以打印出汉字了。

    那么我建议你首先确认打印机是否是多语言支持的,然后用上面这段代码打印汉字。



    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    • 已标记为答案 Paul Zhou 2011年12月19日 7:54
    2011年12月13日 7:28