添加统一code / UTF8字符在C一ncurses的显示 [英] Adding Unicode/UTF8 chars to a ncurses display in C

查看:316
本文介绍了添加统一code / UTF8字符在C一ncurses的显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图增加wchar_t的统一code字符ncurses的一个用C显示。

I'm attempting to add wchar_t Unicode characters to an ncurses display in C.

我有一个数组:

wchar_t characters[]={L'\uE030', L'\uE029'}; // containing 2 thai letters, for example 

和我后来尝试从阵列添加wchar_t中的ncurses的带显示:

And I later try to add a wchar_t from the array to the ncurses display with:

add_wch(characters[0]);

要提供更多的信息,以ASCII做这个工作正常,使用:

To provide a bit more info, doing this with ASCII works ok, using:

char characters[]={'A', 'B'};

// and later...

addch(characters[0]);

要设置的语言环境,我添加了包括...

To setup the locale, I add the include...

#include <locale.h>

// in main()
setlocale(LC_CTYPE,"C-UTF-8");

Ncurses的包括是:

The ncurses include is:

#include <ncurses.h> 

与编译:

(编辑:加入C99标准,通用字符名支持)

(edit: added c99 standard, for universal char name support.)

gcc -o ncursesutf8 ncursesutf8.c -lm -lncurses -Wall -std=c99

我得到以下编译警告(当然可执行文件会失败):

I get the following compilation warning (of course the executable will fail):

ncursesutf8.c:48: warning: implicit declaration of function ‘add_wch’

我刚开始使用这些尝试似乎是macro'ed与wchar_t的工作,但 addch 当我做了统一code字符显示不出来,而是显示为ASCII字符来代替。

I've tried just using addch which appears to be macro'ed to work with wchar_t but when I do that the Unicode chars do not show up, instead they show as ASCII chars instead.

有什么想法?

我使用的OS X雪豹,10.6.6

I am using OS X Snow Leopard, 10.6.6

编辑:在去除错误的wchar_t [] 分配使用 L'\\ u0E30'而不是 L\\ u0E30等。
 我也更新了编译器设置使用C99(添加通用字符名支持)。这两个变化不会解决问题。

removed error on wchar_t [] assignment to use L'\u0E30' instead of L"\u0E30" etc. I've also updated the compiler settings to use C99 (to add universal char name support). both changes do not fix the problem.

不过这个没有答案,没有人知道该怎么办统一code ncurses的 addchar (add_wchar?)!帮帮我!

Still no answers on this, does anyone know how to do Unicode ncurses addchar (add_wchar?) ?! Help!

推荐答案

宽字符支持由ncursesw处理。根据你的发行版,ncurses的可能或不可能(貌似不是你的)点在那里。

The wide character support is handled by ncursesw. Depending on your distro, ncurses may or may not point there (seemingly not in yours).

尝试使用 -lncursesw 而不是 -lncurses

另外,对于区域设置,尝试调用的setlocale(LC_ALL,)

Also, for the locale, try calling setlocale(LC_ALL, "")

这篇关于添加统一code / UTF8字符在C一ncurses的显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆