msgfmt波兰文本上的"无效多字节序列"错误

CW *_* II 6 linux gettext internationalization

使用完整的C++ i18n gettext()"hello world"示例我将语言环境从" es_MX"改为" pl_PL",文本改为"hello,world!" "输入无效.输入一个至少20个字符的字符串." 波兰语翻译包含几个导致msgfmt"łąźó"的"无效多字节序列"错误的字符.翻译的文本是从网页复制的.

我认为utf8是问题所在.如果是这样,应该使用什么呢?

cat >plt.cxx <<EOF
// plt.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
int main (){
    setlocale(LC_ALL, "");
    bindtextdomain("plt", ".");
    textdomain( "plt");
    std::cout << gettext("Invalid input. Enter a string at least 20 characters long.") << std::endl;
}
EOF
g++ -o plt plt.cxx
xgettext --package-name plt --package-version 1.2 --default-domain plt --output plt.pot plt.cxx 
msginit --no-translator --locale pl_PL --output-file plt_polish.po --input plt.pot
sed --in-place plt_polish.po --expression='/#: /,$ s/""/"Nieprawid?owo wprowadzone dane. Wprowad? ci?g przynajmniej 20 znaków."/'
mkdir --parents ./pl_PL.utf8/LC_MESSAGES
msgfmt --check --verbose --output-file ./pl_PL.utf8/LC_MESSAGES/plt.mo plt_polish.po
LANGUAGE=pl_PL.utf8 ./plt
Run Code Online (Sandbox Code Playgroud)

Dou*_*der 8

编辑plt_polish.po并将Content-Type行更改为"Content-Type:text/plain; charset = UTF-8 \n"(将字符集从ASCII更改为UTF-8)