unicode的韩文如何转换为char型的中文

CrazyBW 2014-02-12 05:24:05
RT
我使用WideCharToMultiByte来转换,codepage是949,结果还是乱码,这咋整?
另外既有韩文又有中文的字符串怎么处理成char型的?
求高人指点~!
...全文
271 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
vipcxj 2014-02-17
  • 打赏
  • 举报
回复
windows下的多字节字符串的显示是根据locle来的,所以如果是中文locale,自然是显示不了韩文的,你setlocale一下,在程序里改成韩文字符集试试~
赵4老师 2014-02-17
  • 打赏
  • 举报
回复
引用 2 楼 CrazyBW 的回复:
[quote=引用 1 楼 zhao4zhong1 的回复:] 仅供参考
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = FALSE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void ShowTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = TRUE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
int main() {
    HWND  hwnd;
    HDC   hdc;
    HFONT hfont;

    system("color F0");
    system("cls");
    HideTheCursor();
    hwnd  = GetConsoleWindow();
    hdc   = GetDC(hwnd);
    hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, 0             , 0, 0, 0, 0, "Arial Unicode MS");
    SelectObject(hdc,hfont);
    TextOutW(hdc,10,10,L"你好",2);
    DeleteObject(hfont);
    hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, JOHAB_CHARSET , 0, 0, 0, 0, "Arial Unicode MS");
    SelectObject(hdc,hfont);
    TextOutW(hdc,10,80,L"\xb7f0\xb7f0\xb2dd\xb2dd",4);
    DeleteObject(hfont);
    ReleaseDC(hwnd,hdc);
    getch();
    system("color 07");
    system("cls");
    ShowTheCursor();
    return 0;
}
这是啥。。。。。。。[/quote] 编译链接运行看显示啥。
CrazyBW 2014-02-13
  • 打赏
  • 举报
回复
引用 4 楼 vipcxj 的回复:
韩文怎么可能自动变中文啊,难道LZ要做翻译程序?
说错了 是unicode下的韩文转换成char下的韩文
vipcxj 2014-02-13
  • 打赏
  • 举报
回复
不过韩文也有汉字,貌似是包含在CJK里的,LZ或许可以试试iconv,
vipcxj 2014-02-13
  • 打赏
  • 举报
回复
韩文怎么可能自动变中文啊,难道LZ要做翻译程序?
CrazyBW 2014-02-13
  • 打赏
  • 举报
回复
求回复呀~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
赵4老师 2014-02-13
  • 打赏
  • 举报
回复
赵4老师 2014-02-13
  • 打赏
  • 举报
回复
引用 6 楼 CrazyBW 的回复:
[quote=引用 4 楼 vipcxj 的回复:] 韩文怎么可能自动变中文啊,难道LZ要做翻译程序?
说错了 是unicode下的韩文转换成char下的韩文[/quote] 如果你安装和使用的不是韩文Windows的话,根本就不存在所谓“char下的韩文”
CrazyBW 2014-02-12
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
仅供参考
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = FALSE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void ShowTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = TRUE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
int main() {
    HWND  hwnd;
    HDC   hdc;
    HFONT hfont;

    system("color F0");
    system("cls");
    HideTheCursor();
    hwnd  = GetConsoleWindow();
    hdc   = GetDC(hwnd);
    hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, 0             , 0, 0, 0, 0, "Arial Unicode MS");
    SelectObject(hdc,hfont);
    TextOutW(hdc,10,10,L"你好",2);
    DeleteObject(hfont);
    hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, JOHAB_CHARSET , 0, 0, 0, 0, "Arial Unicode MS");
    SelectObject(hdc,hfont);
    TextOutW(hdc,10,80,L"\xb7f0\xb7f0\xb2dd\xb2dd",4);
    DeleteObject(hfont);
    ReleaseDC(hwnd,hdc);
    getch();
    system("color 07");
    system("cls");
    ShowTheCursor();
    return 0;
}
这是啥。。。。。。。
赵4老师 2014-02-12
  • 打赏
  • 举报
回复
仅供参考
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = FALSE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void ShowTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = TRUE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
int main() {
    HWND  hwnd;
    HDC   hdc;
    HFONT hfont;

    system("color F0");
    system("cls");
    HideTheCursor();
    hwnd  = GetConsoleWindow();
    hdc   = GetDC(hwnd);
    hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, 0             , 0, 0, 0, 0, "Arial Unicode MS");
    SelectObject(hdc,hfont);
    TextOutW(hdc,10,10,L"你好",2);
    DeleteObject(hfont);
    hfont = CreateFont(48, 0, 0, 0, 0, 0, 0, 0, JOHAB_CHARSET , 0, 0, 0, 0, "Arial Unicode MS");
    SelectObject(hdc,hfont);
    TextOutW(hdc,10,80,L"\xb7f0\xb7f0\xb2dd\xb2dd",4);
    DeleteObject(hfont);
    ReleaseDC(hwnd,hdc);
    getch();
    system("color 07");
    system("cls");
    ShowTheCursor();
    return 0;
}

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧