![]() |
#2
wp2319572013-01-20 13:39
|
至于该字符串由ASCII字符组成或由Unicode字符组成,取决于是否定义了UNICODE标识符。”
撸主突然想到在Win32汇编里,它是怎么确定用哪个版本的,于是撸主用MessageBox做下实验,写了一段代码:

.386
.model flat, stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
.const
szMsgText db '几时心绪浑无事,得几游丝百尺长?',0
szCaption db '诗句',0
.code
start:
invoke MessageBoxA,NULL,offset szMsgText,offset szCaption,MB_OK
mov eax, sizeof szCaption
.if eax == 5
invoke MessageBox, NULL, NULL, NULL, MB_OK
.endif
invoke ExitProcess,NULL
end start
.model flat, stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
.const
szMsgText db '几时心绪浑无事,得几游丝百尺长?',0
szCaption db '诗句',0
.code
start:
invoke MessageBoxA,NULL,offset szMsgText,offset szCaption,MB_OK
mov eax, sizeof szCaption
.if eax == 5
invoke MessageBox, NULL, NULL, NULL, MB_OK
.endif
invoke ExitProcess,NULL
end start
使用eax对szCaption的长度进行判断时,撸主试了几次,惊奇的发现它的长度居然是5!中文的确是用两个byte表示了,但最后一个0仍然是一个byte!
问题有:
一、使用MessageBoxA的时候没有任何问题,但是为什么可以呢?这个不是只能处理ASCII字符串么??
二、修改下代码,使用MessageBoxW的时候就会产生乱码,为什么呢?
三、再修改一下代码,将两个字符串用DW定义,这时候编译就不能通过了:“constant value too large”,这是为什么?撸主注意到使用ml编译的时候
有个提示 ASCII build, 所有这些问题是不是都跟这个有关?
好吧,坐等各路大神解答
