osimer pothe
osimer pothe

Reputation: 2897

How to show Bengali Language in Codeblocks

I am facing a problem to show Bengali language output in codeblocks . I want to write Bengali language .I know it can be done with the help of unicode . The unicode of "ঈ" is 2440 . So I write the following small program .

       #include<stdio.h>

       int main()
       {
           int i;
           char ch = 2440;
           printf("%c",ch);
           return 0;
      }

But the above program does not show "ঈ" . Why ? What should I do in order to show Bengali language in codeblocks .Plz guyz help me to solve this problem .

Upvotes: 3

Views: 1561

Answers (1)

Karthik T
Karthik T

Reputation: 31952

When you use char, it is stored in 1 byte, and thus can only store up-to 256 (or -127 - 128). This means that 2440 will get truncated, and that's one reason why it is not working.

Instead of printf and char you need to use functions and types from wchar.h, specifically wchar_t and something like wprintf .

 wprintf (L"Character: %lc %lc \n", L'ঈ', 2440);

p.s. I realise they are c++ based resources, but they are talking about the C library, and they should work regardless.

Upvotes: 7

Related Questions