您的帖子包含两者
U+000041 拉丁文大写字母 A (A)
和
U+000410 西里尔大写字母 A (А)
无论哪种方式,您都需要使用终端期望的编码对字符进行编码。假设终端需要 UTF-8,
$ perl -e'use utf8; $_ = "A"; utf8::encode($_); printf "%v02X", $_;'
41
$ perl -e'use utf8; $_ = "\N{U+41}"; utf8::encode($_); printf "%v02X", $_;'
41
$ perl -e'use utf8; $_ = chr(0x41)"; utf8::encode($_); printf "%v02X", $_;'
41
$ perl -e'use utf8; $_ = "А"; utf8::encode($_); printf "%v02X", $_;'
D0.90
$ perl -e'use utf8; $_ = "\N{U+410}"; utf8::encode($_); printf "%v02X", $_;'
D0.90
$ perl -e'use utf8; $_ = chr(0x410); utf8::encode($_); printf "%v02X", $_;'
D0.90
所以你想要
const char *str = "\x41"; // { 0x41, 0 }
printf("%s\n", str); // write(1, str, 1);
或
const char *str = "\xD0\x90"; // { 0xD0, 0x90, 0 }
printf("%s\n", str); // write(1, str, 2);
(使用write 没有意义,但你可以。)