title: Create UTF-16 string from char*
body: <p>So I have standard C string:</p>
  
  <pre><code>char* name = "Jakub";
  </code></pre>
  
  <p>And I want to convert it to UTF-16. I figured out, that UTF-16 will be <strong>twice as long</strong> - one character takes <strong>two</strong> chars.<br>
  So I create another string:</p>
  
  <pre><code>char name_utf_16[10];  //"Jakub" is 5 characters
  </code></pre>
  
  <p>Now, I believe with ASCII characters I will only use lower bytes, so for all of them it will be like <code>74 00</code> for <code>J</code> and so on. With that belief, I can make such code:</p>
  
  <pre><code>void charToUtf16(char* input, char* output, int length) {
      /*Todo: how to check if output is long enough?*/
      for(int i=0; i&lt;length; i+=2)  //Step over 2 bytes
      {
          //Lets use little-endian - smallest bytes first
          output[i] = input[i];
          output[i+1] = 0;  //We will never have any data for this field
      }
  }
  </code></pre>
  
  <p>But, with this process, I ended with <code>"Jkb"</code>. I know no way to test this properly - I've just sent the string to Minecraft Bukkit Server. And this is what it said upon disconnecting:</p>
  
  <blockquote>
    <p>13:34:19 [INFO] Disconnecting <strong>jkb</strong>?? [/127.0.0.1:53215]: Outdated server!</p>
  </blockquote>
  
  <p><strong>Note:</strong> I'm aware that Minecraft uses big-endian. Code above is just an example, in fact, I have my conversion implemented in class.</p>