Android java conversion problem
<p>I have currently the problem that I like to send some commands to an embedded devices via bluetooth (encoded in 16 bits). Unfortunately there seems to be a conversion error in Java or at least I don't know how to handle it.</p>

<p>These bits are e.g. 1001 0010 1011 0010 
I thought about using char for this (16bit), but sometimes it's converted by Java to 24 bits (3 printed characters), when I try to add it to a string. This depends on the integer value.</p>

<p>How can I get the printed ASCII (or whatever) characters here? The bluetooth-function requires a String as parameter.</p>

<pre><code>        int a = 127, b = 221;  // 0-255  32 bit
            char p1 = (char) b; // 0000 0000 bbbb bbbb  16 bit
            char p2 = (char) a; // 0000 0000 aaaa aaaa  16 bit

            // bbbb bbbb aaaa aaaa
        char anUnsignedShort = (char) ((p1 &lt;&lt; 8) | p2);  // 16 bit
        System.out.println(""+(char)2+anUnsignedShort+(char)3);
        // ???? ???? bbbb bbbb aaaa aaaa  -- 24bits sometimes. Why ???
</code></pre>
