如何将马拉雅拉姆语作为c/c ++程序输出打印?

JER*_*ERY 5 c unicode winapi encoding

我正在尝试将Malayalam(南印度语)打印为c/c ++程序输出,但它在终端和用户界面中使用WINAPI显示了一些不熟悉的字符.

(文件"malayalam.txt"包含一些马拉雅拉姆语单词.)

#include <stdio.h>
#include <windows.h>

main() {
    char s[100];
    FILE *fp;
    fp = fopen("malayalam.txt", "r");   
    if (fp == NULL) {
        puts("Cannot open file");
    }
    while (fgets(s, 100, fp) != NULL) {
        printf("%s", s);
        MessageBox(NULL, s, "Malayalam", MB_OK);
    }
    fclose(fp);
}
Run Code Online (Sandbox Code Playgroud)

Vin*_*kla 4

以下链接中的示例可能会帮助您解决 WINAPI 的此问题。

您需要在文件中找到与您的马拉雅拉姆语单词对应的 unicode,.txt您可以从这里进行转换http://www.aksharangal.com

以下页面的示例http://harikrishnanvs.blogspot.in/2011/12/printing-malayalam-as-c-program-output.html

WIN32 程序用马拉雅拉姆语打印我的名字 -MessageBox

这适用于 Windows 7,但不适用于 XP 在 Visual Studio 2010 中创建新项目。 文件-->新建-->项目-->Win32 项目 为项目命名,单击“确定”完成

包括头文件stdafx.htchar.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;
}
Run Code Online (Sandbox Code Playgroud)

请确保配置属性--->字符集--->使用Unicode字符集选项被选中。