|
|
实验网上一关于gettext的例子,怎么输出中文有点不对啊,各位帮忙看看!!
下面为源程序,程序名为:this_app.c
#include <locale.h>
#include <libintl.h>
#define _(String) gettext(String)
#define N_(String) gettext(String)
#define __(String) gettext(String)
int main()
{
setlocale(LC_ALL, "");
bindtextdomain("this_app", "/usr/share/locale");
textdomain("this_app");
printf(_("Somt String"));
}
运行:xgettext -a -o this_app.po this_app.c
this_app.c:9: warning: Empty msgid. It is reserved by GNU gettext:
gettext("") returns the header entry with
meta information, not the empty string.
修改this_app.po文件,翻译中文:
#: this_app.c:12
msgid "Somt String"
msgstr "一些字符串"
运行 msgfmt -o this_app.mo this_app.po
msgfmt: this_app.po: warning: Charset "CHARSET" is not a portable encoding name.
Message conversion to user's charset might not work.
运行:cp this_app.mo /usr/share/locale/zh_CN/LC_MESSAGES
执行文件: LC_ALL=zh_CN ./this_app
输出:
涓?浜涘瓧绗︿覆
这么会是一些乱码啊???
我用的是RedHat 9.0系统.
小弟先谢谢了!! |
|