Tuesday, December 20, 2011

Printing Malayalam as C program output at dos prompt, win32

Hai all,

I think we cannot print Malayalam letters in dos prompt. If any body gets a solution, please let me know.

I was just trying to print the malayalam letters using a C Program in windows. I used Visual Studio 2010 to run my  C++ program. Following is program:

Use header files like windows.h, conio.h, tchar.h etc

int _tmain(int argc, _TCHAR* argv[])
{
    TCHAR c;
    SetConsoleOutputCP(863);
    printf("\nHello SDL User!\n");
    printf ("The codepage is %d\n", GetConsoleOutputCP());
    for(c= 3333;c<3455;c++)
    {
              _tprintf(TEXT("%lc\n"),c);
    }
    getch();
    return 0;
}

c= 3333 is the decimal value  of UNICODE for first malayalam letter 'അ'  (0x0D05-hex value).
Ref: http://www.malayalamunicode.com/malayalam-unicode-fonts

But the output was
?
?
?
.
.
.
Why this is because the DOS supports only a few languages whose list can be seen by checking the codepages supported by DOS in following link.
Ref 1: http://en.wikipedia.org/wiki/Category:DOS_code_pages

For Malayalam to be displayed DOS must support code page
57009x-iscii-maISCII Malayalam
 This code page is not supported by DOS as listed in above reference.
Ref 2:http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx

So Sad that unless DOS provides a support for this, we cannot print a malayalam letter in DOS

WIN32 program to print my name in Malayalam --MessageBox
-------------------------------------------------------------
This works for windows 7, but not working in XP
Create new project in visual studio 2010.
File-->New-->Project-->Win32 Project
Name the project
click OK
Finish

include header files stdafx.h, tchar.h.

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, PSTR szCommandline,int iCmdshow)
{
    TCHAR c[4];
    c[0]=3385;
    c[1]=3376;
    c[2]=3391;
    c[3]='\0';
    TCHAR szbuffer[100];
   
    _stprintf(szbuffer,_T("%ls"),c);
    MessageBox(NULL,szbuffer,TEXT("HELLO ALL"),0);
    return 0;
}


Please ensure that , Configuration Properties--->Character set---> Use Unicode Character Set option is selected.




No comments: