Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I use datamax printer , I send to serial port by c# software to print arabic in labels

serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.Open();
//serialPort1.Encoding = Encoding.GetEncoding("windows-1256");
serialPort1.Encoding = Encoding.ASCII;
serialPort1.Write("\x02" + "L" + "\x0D");
serialPort1.Write("D12" + "\x0D");

serialPort1.Write("H20" + "\x0D");
string test_arab = "الحملله";
serialPort1.Write("190000202600010 " + test_arab + "\x0D");//text
//serialPort1.Write("B" + test_arab + "\x0D");
serialPort1.Write("Q" + ' ' + test_arab + "\x0D");
serialPort1.Write("E" + "\x0D");
serialPort1.Close();


the result in labels like this "???????"

how can i print arabic like "الحمد لله"
Posted
Comments
[no name] 12-Apr-15 20:38pm    
Printer model #?

Thanks to all
the solution...
///////////////////////////////////////////////////////////////////
serialPort1.Open();
serialPort1.Encoding = Encoding.GetEncoding("ASMO-708");
serialPort1.Write("\x02" + "L" + "\x0D");
serialPort1.Write("D12" + "\x0D");
serialPort1.Write("H20" + "\x0D");
serialPort1.Write("ySPR" + "\x0D");
string test_arab = "مصر جميلة";
string test_arab2 = "ثورتنا 25";
serialPort1.Write("1911SA001900050P020P020" + a.Arabize(test_arab) + "\x0D");
serialPort1. Write("1911SA001100050P020P020" + a.Arabize(test_arab2) + "\x0D");
serialPort1.Write("Q" + "\x0D");
serialPort1.Write("E" + "\x0D");
serialPort1.Close();
 
Share this answer
 
v2
Comments
ebrahimessa 17-Dec-15 10:21am    
what is 'a' object you used to arabize text
could you provide it
This is simple: Perso-Arabic script is not represented in ASCII at all. With all modern systems, you need to use Unicode, and for encoding, some Unicode UTF.

Also, I'm not sure that your printer supports this script directly and, even if it does, I have no idea what encoding is required. Address the printer documentation. If the script is not supported, you may need to print all such data in graphics.

—SA
 
Share this answer
 
v2
You need to talk to the manufacturers: Serial port data doesn't have any intrinsic "font" information - it doesn't even have a character set in the sense that Windows and C# does with Unicode.

Only the manufacturers can tell you that as it can vary from model to model, never mind manufacturer to manufacturer - which is why printing almost always is done via device driver software provided by the manufacturer as a software installation with the hardware.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Apr-15 11:53am    
Sorry, "font" is your own fantasy: the inquirer's question is original, there are no version, and no a sign of such a stupid idea. If you try to attribute the possible stupid ideas to the inquirers, it won't help anyone.

Serial ports don't have "character set" or "encoding", but in the same sense as CPUs, memory and disk volumes: they also don't have encoding, but we use different encodings. Likewise, the SerialPort class does have the property Encoding, and this property has perfect sense: the port itself only work with byte, but the class allows the users to work with strings and this property defines how strings are represented as bytes.

"Talk to manufacturer" is also confusing. It should be the printer manufacturer. All your post talks about serial port only, which is not very relevant to anything manufacture-specific... :-)

Sorry,
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900