注意:
/*
* Trivial code
*/
wchar_t *greeting = L"Hello World!";
char *greeting_ = "Hello World!";
WinDbg:
0:000> ?? greeting
wchar_t * 0x00415810
"Hello World!"
0:000> ?? greeting_
char * 0x00415800
"Hello World!"
0:000> db 0x00415800
00415800 48 65 6c 6c 6f 20 57 6f-72 6c 64 21 00 00 00 00 Hello World!....
00415810 48 00 65 00 6c 00 6c 00-6f 00 20 00 57 00 6f 00 H.e.l.l.o. .W.o.
00415820 72 00 6c 00 64 00 21 00-00 00 00 00 00 00 00 00 r.l.d.!.........
问题:
- NULL 字符的用途是什么:
wchar_t
中 ASCII 字符之间的00
- Win32?
最佳答案
wchar_t
是一个宽字符字符串,所以每个字符占用 2 个字节的存储空间。 'H' 作为 a wchar_t
是 0x0048。由于 x86 是小端字节序,您会看到内存中的字节顺序为 48 00。
windbg 中的 db 将转储字节并提供如何将其视为 ASCII 字符串,因此 H.E.L. ...你看到的输出。您可以使用“du”将内存转储为 unicode 字符串。
关于c++ - wchar_t 和 char 在 WinDbg 中的表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/766126/