bluetooth receipt printer - cannot change codepage of printer
<p>I have a following setup:</p>

<ol>
<li>Workstation with <code>Ubuntu 14.04.3 LTS</code> using kernel <code>Linux work002 3.19.0-47-generic #53~14.04.1-Ubuntu SMP Mon Jan 18 16:09:14 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux</code> with <code>Qt 5.5.1 Opensource 64bit</code></li>
<li>Some <strong>usb&lt;-->bluetooth</strong> dongle, which has been working just fine</li>
<li><strong>Bluetooth</strong> based noname 48mm receipt printer from China, which was shipped to me without any documentation (assuming <strong><code>ESC/POS</code> command set</strong>).</li>
</ol>

<p>Now, this setup seems (initial connection, pairing and once paired <strong>blue</strong> <code>LED</code> diode turns on on printer) to work because I can print some text on the printer via <a href="http://doc.qt.io/qt-5/qiodevice.html#write-1" rel="nofollow">QBluetoothSocket::write</a> method:</p>

<pre><code>this-&gt;ueBtPrinterSocket()-&gt;write(QByteArray("Printer ready. @[\\]^`{|}~ ĐŠŽĆČđšžćč"));
</code></pre>

<p>However, I am from Slovenia and I need Slovene letters, that is why i put Slovene letters into upper <code>write</code> - <code>ĐŠŽĆČđšžćč</code> and I get some Chinese letters instead. Therefore I tried to change printer code page according to <a href="https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=32" rel="nofollow">ESC t n function</a>, but without success:</p>

<pre><code>QByteArray cmdChangeCodePageToSlovene;    // ESC t n
cmdChangeCodePageToSlovene.resize(3);
cmdChangeCodePageToSlovene[0]=0x1b;
cmdChangeCodePageToSlovene[1]=0x74;
cmdChangeCodePageToSlovene[2]=0x18;
qint64 result=this-&gt;ueBtPrinterSocket()-&gt;write(cmdChangeCodePageToSlovene);

qDebug() &lt;&lt; Q_FUNC_INFO
         &lt;&lt; " bytes written:"
         &lt;&lt; result;
</code></pre>

<p><code>qDebug()</code> output notified me:</p>

<blockquote>
  <p>void UeBluetoothManager::ueSlotBtPrinterPairedAndConnected()  bytes
  written: 3</p>
</blockquote>

<p>which is ok. Now, the Chinese manufacturer finally sent me some code for <code>Android</code>, which can be hardly called SDK and there is single <code>.jar</code> library for working with printer. I've uploaded this <code>.jar</code> file to <a href="http://www.javadecompilers.com/result?currentfile=com/printer/ZQPrinter.java" rel="nofollow">Decompilers online</a> website and I've found following decompiled method for changing printer's codepage:</p>

<pre><code>public int SetCharacterSet(int Value) {
    if (g_nConnect != 1) {
        return 101;
    }
    if (!(Value &gt; 0 &amp;&amp; Value &lt; 10 || Value &gt; 16 &amp;&amp; Value &lt; 19 || Value != 255)) {
        return 104;
    }
    byte[] send = new byte[]{27, 116, 1};
    send[2] = (byte)Value;
    try {
        out.write(send);
        return 0;
    }
    catch (IOException e) {
        e.printStackTrace();
        return 402;
    }
}
</code></pre>

<p>which is basically same as my <code>Qt</code> code for changing codepage of printer (and because of that I can assume with high probability that printer command set is at least basic <code>ESC/POS</code>), so I can assume I am on the right track. Now, I've checked bluetooth traffic using <code>Wireshark</code>, however, I cannot find <code>0x1b 0x74 18</code> (command to change codepage) datastream sent to printer. Is this maybe the reason the codepage is not changed or can someone give me please some guidelines? I've also tried to change codepage to <code>Windows-1250</code> and <code>ISO8859-2: Latin 2</code>, no effect.</p>