Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I`m going to print out Arbic recipt print by using C#(.NET 2.0)
Please see each code as below by Serial interface.

byte[] cutemp = Encoding.GetEncoding(1256).GetBytes(content);
serialPort.BaseStream.WriteTimeout = 1500000;
serialPort.BaseStream.Write(cutemp, 0, cutemp.Length);
serialPort.BaseStream.Flush();


BUT, the problem is that Arbic print out in reverse.(Up side down)
When mix English and Arbic, English print out well, only arabic has been reversed.
As I checked converted Byte arrangment, converted byte has been reversed after encoding.
for example, if 54321(please imagine these would be Arabic) and encoding these letters,
Byte arrangement [1][2][3][4][5] instead of [5][4][3][2][1], something like this.

anybody help me out?!!
My boss is waiting for me to kill if I don`t fix this problem.
Posted
Updated 9-Aug-10 22:50pm
v2
Comments
Sandeep Mewara 10-Aug-10 9:35am    
If he tries to kill you then ask him to fix it before doing the honor! :P

Isn't it kind of logical? The English language is read LTR (left to right) and Arabic RTL (right to left) and since the serial port doesn't have support for something like like html does this is something you have to do yourself. I guess you could reverse the string after you get it with BigEndianUnicode, so reversing the byte array is correcting it, making it possible to read it as little endian on the receiving side. This would be for the arabic text only of course.

http://www.tertullian.org/rpearse/RightToLeft_Syriac/right_to_left.htm[^]

http://msdn.microsoft.com/en-us/library/system.text.encoding.bigendianunicode%28v=VS.71%29.aspx[^]

http://msdn.microsoft.com/en-us/library/system.text.encoding.bigendianunicode%28v=VS.71%29.aspx[^]

Good luck!
 
Share this answer
 
v2
Comments
TaeGyu Kang 10-Aug-10 19:35pm    
Thanks for your help~
I'll give you another option. Does this receipt printer print monochrome bitmap images?

Why not write the Arabic text to a bitmap, then send the bitmap to the printer? This will guarantee that the text you write will be the text that prints. You can even flip it, reverse it, or turn it 90 degrees, because we both know that the customer is going to want that eventually anyway.

It's been about five years since I last did this, and it was on a Printech printer over a serial cable or bluetooth from a Windows CE device. Images were slow to print compared to text. This will be compounded if you have a customer tapping his foot waiting for a receipt, but transmission speed might have improved since I did this. But there is a way around this as well. Some printers have a memory buffer that you can load with images. If you preload Arabic images for words like "Total" or "Subtotal" in the memory buffer, all you have to do is send a command, and the items will print without having to send the whole bitmap.

Ryan
 
Share this answer
 
Comments
TaeGyu Kang 10-Aug-10 22:36pm    
Thanks for your help~ :)

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