Android Question problem with use writestring2

lelelor

Member
Licensed User
Hello, I'm using writestring2 (core) to use a code page to print the "€" symbol with escpos.
With VB6 this succeeds me, in B4A

I write this line
Printer1.WriteString2 ("€" & CRLF, "858")

and makes me the mistake
Printer error: java.lang.IllegalArgumentException: Null charset name

I know that the code page where the "€" symbol is resident is 858, it is likely that I write the command incorrectly, can you help me?
Thank you
 

lelelor

Member
Licensed User
NOW is set to IBM437
B4X:
 public Sub WriteString(data As String)
	WriteString2(data, "IBM437")
End Sub
but does not print "€" to me with VB6 codepage6 of escpos with sequence

B4X:
 Chr (27) & Chr (116) & Chr (6) & vbCrLf

prints "€" to me
i don't know how to transform this string with B4A
 
Upvote 0

lelelor

Member
Licensed User
this is the answer of SUNMI manufacturer

The easiest way is to use our print pick-up printText, you can call printing directly PrintText ("$ ¥ € £ ₣ N", null) If it is a developer printed with the ESC instruction, it corresponds to the different currency symbols, printing special characters.
The character set is not necessarily the same. It is recommended to use the UTF-8 character we specified (the device default is GB18030), and the setting of the character set FAQ7; For example, still print $ ¥ € € £ ₣ These symbols:
Need to send the instruction byte [] data = new byte [] {0x1c, 0x26, 0x1c, 0x43, 0xff} Set the printer receive UTF-8 character encoding Then sends the corresponding symbol data "$ ¥ € £ ₣" .GetBytes ("UTF-8") which is:
Senddata (New Byte [] {0x1c, 0x26, 0x1c, 0x43, 0xff}, null Senddata ("$ ¥ € £ ₣" .GetBytes ("UTF-8")

i don't understand what printtext is, sorry but i'm self taught and it's hard for me to understand
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
It's garbled but I think they are saying that you can set the printer to accept UTF-8 character sequences. The command sequence they give is an invalid definition of a downloaded custom character. This could be specific to their printer as the ESC/POS standard seems to assume the text is sent as values in a 256 character code page
Add the following Sub to the EscPosPrinter module, call it instead of setCodepage, then try using WriteString2(data, "UTF8")
B4X:
Public Sub setUTF8
    Dim params(5) As Byte
    params(0) = 0x1c
    params(1) = 0x26
    params(2 = 0x1c
    params(3) = 0x43
    params(4) = 0xff 
    WriteBytes(params)
End Sub
I've looked on the SUMNI web sote but I can't find manual for a thermal printer there. What's your device and do you have a manual for it?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Found something :) The printer does support multi-byte encoding via non-standard command sequences as follows. What I said above should work. Here is also the list of single byte encodings supported.
7. How to select and set a character set. Background: the inbuilt printers are compatible with the transmission in a form of
binary byte stream, so a character set must be selected and set for the text to be printed
which is sent in a form of byte code; multi-byte, GB18030 character encoding are the
default device settings. The single-byte encoding types for inbuilt printers are:
[参数] [编码] [国家]
[Parameter] [Encoding] [Country]
0 "CP437"; 美国欧洲标准 The USA, European standard
2 "CP850"; 多语言 Multiple languages
3 "CP860"; 葡萄牙语 Portuguese
4 “CP863"; 加拿大 -法语 Canada - French
5 “CP865"; 北欧 Northern Europe
13 "CP857"; 土耳其语 Turkish
14 "CP737"; 希腊语 Greek
15 "CP928";
16 "Windows-1252";
17 "CP866"; 西里尔文 Cyrillic
18 "CP852"; 拉丁-中欧语 Latin - Central European
19 "CP858";
21 "CP874";
33 "Windows-775"; 波罗的海语 Baltic
34 "CP855"; 西里尔文 Cyrillic
36 "CP862"; 希伯来语 Hebrew
37 "CP864";
254 "CP855"; 西里尔文 Cyrillic
The multiple-byte encoding types for inbuilt printers are:
[参数] [编码]
[Parameter] [Encoding]
0x00 || 0x48 "GB18030";
0x01 || 0x49 "BIG5";
0xFF “utf-8”;
The device settings can be adjusted in accordance to the needs of different countries
or other requirements to enable the printers to identify the data stream of the content to
be printed. To print CP437, please send:
0x1C 0x2E ——set it as the single-byte encoding type
0x1B 0x74 0x00 ——set it as the CP437 of the single-byte code page
To print CP866, please send:
0x1C 0x2E ——set it as the single-byte encoding type
0x1B 0x74 0x11 ——set it as the CP866 of the single-byte code page
To print traditional characters, please send:
0x1C 0x26 ——set it as the multiple-byte encoding type
0x1C 0x43 0x01—— set it as the BIG5 encoding of the multiple-byte code page
To print UTF-8 encoding content (all Unicode character sets are supported if using
UTF-8 encoding, and all content can be printed), please send:
0x1C 0x26 ——set it as the multiple-byte encoding type
0x1C 0x43 0xFF—— Set it as the UTF-8 encoding of the multiple-type code page
 
Upvote 0
Top