[英]character encoding in libc?
What is the character encoding expected in libc? libc中预期的字符编码是什么? For example, gethostname(char name, size_t namelen);
例如,gethostname(char name,size_t namelen); takes char as argument.
以char为参数。 Is it expected that the name parameter be encoded in utf8(which keeps the ascii intact) or plain ascii or some other format?
是否期望name参数在utf8(保持ascii完整)或plain ascii或其他格式中编码?
Also does C mandates any character encoding scheme? C还要求任何字符编码方案吗?
所有字符串函数(widechar除外)都只支持本机字符集,例如Unix / Linux / Windows上的ASCII或IBM大型机/中型计算机上的EBCDIC。
use and in order to deal with the wide characters. 使用和处理广泛的人物。
char
should be a 7-bit compatible ASCII encoding (I can't find any definite reference on this though). char
应该是一个7位兼容的ASCII编码(虽然我找不到任何明确的参考)。 The definition of wchar_t
is left to the implementation , but the C standard requires that the characters from the C portable character set be the same. wchar_t
的定义留给实现 ,但C标准要求C可移植字符集中的字符相同。 If I understand this correctly, then 如果我理解正确的话,那么
char a = 'a';
wchar_t aw = L'a';
if (a == (char)aw) {
// should be true
}
The standard does not say anything about UTF-8. 该标准没有提及UTF-8的任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.