title: Printing Unicode Character (stored in variables) in C
body: <p>I am to print some <strong>unicode</strong> (4 digit Hex) characters in <strong>C</strong>.</p>
  <p>Those characters I've stored in some <strong>short int</strong> variables. The following is the code I'm supposed to use for my purpose :</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;locale.h&gt;
  #include &lt;wchar.h&gt;
  
  int main(void) {
      
      setlocale(LC_ALL,&quot;&quot;);
  
      short a = 0x099A, b = 0x09BE;
      wchar_t *string1 = (wchar_t *) calloc(20, sizeof(wchar_t));
      sprintf(string1, &quot;\\u%04x\\u%04x&quot;, a, b);
      printf(&quot; %s &quot;, string1);
  
      wchar_t *string2 = (wchar_t *) calloc(20, sizeof(wchar_t));
      strcpy(string2, (wchar_t *) &quot;\u099A\u09BE&quot;);
      printf(&quot; %s \n&quot;, string2);
  
      return 0;
  }
  </code></pre>
  <p>Now the problem is:</p>
  <blockquote>
  <p>although <strong>string2</strong> is showing the corect output in terminal, <strong>string1</strong> isn't.</p>
  <p>But I <strong>must</strong> use the <em><strong>1st</strong></em> approach, i.e I have the unicode characters stored in some arbitrary variables &amp; I need a way to get them printed on screen.</p>
  </blockquote>
  <p>Any suggestion shall be keenly appreciated.</p>