简体   繁体   English

在 C++ 中,é 如何按位移位为 E?

[英]How is é bitwise shifted to a E in C++?

Hello I having trouble understanding this and how for example it take an accent char like é and converts it E9 .您好,我在理解这一点时遇到了麻烦,例如它如何采用像é这样的重音字符并将其转换为E9 I could be missing something i get that it bit-shifts right 4. é = 11101000 and E = 01000101 shifting 4 doesn't make E right?我可能会遗漏一些我知道它向右移位 4 的E = 01000101 é = 11101000E = 01000101移位 4 不会使E正确吗?

static const char *digits = "0123456789ABCDEF";
unsigned char ch;
*dest++ = digits[(ch >> 4) & 0x0F];//this returns E
*dest++ = digits[ch & 0x0F];//this returns 9

The code doesn't convert é to E9 - it converts an 8-bit number to its hexadecimal representation, in four-bit pieces ("nybbles").代码不会将é转换为E9 - 它将 8 位数字转换为其十六进制表示,以四位部分(“nybbles”)表示。

digits[(ch >> 4) & 0x0F] is the digit that represents the high nybble, and digits[ch & 0x0F] is the digit that represents the low nybble. digits[(ch >> 4) & 0x0F]是代表高 nybble 的digits[ch & 0x0F]digits[ch & 0x0F]是代表低 nybble 的数字。

If you see é become E9 , it's because é has the value 233 in your character encoding.如果您看到é变为E9 ,那是因为é在您的字符编码中具有值 233。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM