[英]Print extended ascii with write function
How do I print character 128 from extended ascii with write function in c language? 如何使用C语言中的具有写入功能的扩展ascii打印字符128?
#include <unistd.h>
int main(void)
{
int c;
c = 128;
write(1, &c, 1);
return(0);
}
Output: 输出:
Ascii extended 128: Ç Ascii扩展128:Ç
Using a wchar_t
: 使用wchar_t
:
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
int main(void)
{
wchar_t c;
setlocale(LC_ALL, "");
for (c = 128; c < 256; c++) {
wprintf(L"%lc\n", c);
}
return 0;
}
Write the Unicode version 编写Unicode版本
uint16_t x = 0x87C3; // little endian (beware endianness matters)
write(1, &x, 2);
(a type that has 2 bytes) (具有2个字节的类型)
To remove any endianness issue, use an array instead 要消除任何字节序问题,请改用数组
uint8_t y[] = { 0xC3, 0x87 };
write(1, y, 2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.