English Boards > Support

Configuring printer to use default character set

(1/1)

polymorpher:
My friend has a Chinese restaurant, so all tickets needs to be printed in Chinese (for internal use). The POS printer can print Chinese characters flawlessly on notepad, but on SambaPOS it prints unreadable scribbles no matter what character set I use (tried 936, 850, 852, 0, 65001 and other character sets related to GB2312). Is it possible to let SambaPOS just use the default character set as used in notepad?

polymorpher:
So I briefly looked into the source code. The default character set used in SambaPOS is 857 (Turkish). C# .Net Printing API is invoked in SerialPortService.cs (Samba.Services.SerialPortService) by


--- Code: ---        public static void WritePort(string portName, string data)
        {
            WritePort(portName, Encoding.ASCII.GetBytes(data));
        }

--- End code ---
and

--- Code: ---        public static void WritePort(string portName, string data, int codePage)
        {
            WritePort(portName, Encoding.GetEncoding(codePage).GetBytes(data));
        }

--- End code ---

The first one calls for ASCII encoding while the second one use specific code page. Since by default notepad saves everything in ANSI, I guess modifying the second function as follows will solve the problem:

--- Code: ---        public static void WritePort(string portName, string data, int codePage)
        {
            WritePort(portName, codePage==0?Encoding.Default.GetBytes(data): Encoding.GetEncoding(codePage).GetBytes(data));
        }

--- End code ---

Then set character set to 0 if one wants to use system default encoding. I will test it tomorrow.

emre:
Hey Polymorpher, The part you are checking is used for sending data to ports so modifying it will make no change on printing. For printer we use similar implementation. If you search for LinePrinter class you'll find it. I'll be happy if you can help me on understanding if using default encoding will solve it or not..

Thanks

polymorpher:
Thanks Emre. Here is the test result:

It looks like setting encoding to default does not help much in this situation. The problem is resolved by changing printer type to "Text" from "Ticket Printer". I suspect the problematic printer we had does not conform with some standard, because our kitchen printer works perfectly with its printer type set to "Tick Printer".

The same solution might apply to people who run into similar problems (i.e another language, special symbols, etc.).

However, providing an option to use default encoding does save people a lot of trouble to look for the correct character set.

emre:
polymorpher, thank you very much for the feedback. I'll try to simplify that as you suggested.

Navigation

[0] Message Index

Go to full version