I have been using @agraham's library for ESC/POS printing for the last few months and it has worked great. Recently I got a client from the Middle East and they want to print Arabic along with English characters.
I understand that you need to set the codepage corresponding to the language you intend to use. This is the codepage manual of the printer my client uses.
According to the test page printed by the printer, it uses code page Windows-1256 by default, which is what is used to display Arabic characters. The data reaches the app via an HTTP request, in JSON string. This is how the Arabic string looks within the app and my client confirms this is the right form.
But when the same data is printed via the ESC/POS printer, this is how it looks.
I don't know Arabic but visually it looks different and the client confirms the same. The code used to print is this.
The above code prints the incorrect Arabic. I tried the following as well.
The above code prints just random characters so I am assuming the right way is to use WriteString2 and set the custom encoding.
Another interesting thing is that when I showed it to a friend who knows Arabic, he says while the letters printed are correct, they are in the wrong order; as in the letters are printed from Left to Right like in English but in Arabic it should be Right to Left as it is an RTL language. This is all very confusing and without the printer in hand the debug process in incredibly complicated.
So my question is, other than setting custom encoding using WriteString2, should any other parameter be set to indicate the string is in Right to Left form?
I understand that you need to set the codepage corresponding to the language you intend to use. This is the codepage manual of the printer my client uses.
According to the test page printed by the printer, it uses code page Windows-1256 by default, which is what is used to display Arabic characters. The data reaches the app via an HTTP request, in JSON string. This is how the Arabic string looks within the app and my client confirms this is the right form.
But when the same data is printed via the ESC/POS printer, this is how it looks.
I don't know Arabic but visually it looks different and the client confirms the same. The code used to print is this.
B4X:
Printer1.WriteString2(PrintProduct(i).name,"windows-1256")
The above code prints the incorrect Arabic. I tried the following as well.
B4X:
Printer1.WriteString(PrintProduct(i).name)
The above code prints just random characters so I am assuming the right way is to use WriteString2 and set the custom encoding.
Another interesting thing is that when I showed it to a friend who knows Arabic, he says while the letters printed are correct, they are in the wrong order; as in the letters are printed from Left to Right like in English but in Arabic it should be Right to Left as it is an RTL language. This is all very confusing and without the printer in hand the debug process in incredibly complicated.
So my question is, other than setting custom encoding using WriteString2, should any other parameter be set to indicate the string is in Right to Left form?