--- In [email protected], "swzoh" <[EMAIL PROTECTED]> wrote:
> The length of the byteblock "xString" always return 263. I became
> curious why it's not 2*2 or 266:
>
> 266 = 272 - 1 - 4 - 1
>
> where 1-byte header, 4-byte size as int, 1-byte eos.
>
> My conjecture is that the header is not 1-byte, but actually 4-byte.
> Some kind of Struct Packing arose here, I suppose:
>
> 263 = 272 - 4 - 4 - 1
>
> This might be also the cause to not report the correct size of
> "xString" buffer, 2*2=4.
Here is the detail:
----------------------------------------------------------------------
local sString,xString
sString="A"
xString=repeat(1,271)
dll.call("MultiByteToWideChar|ui ui s i x i",;;+
0,0,sString,-1,"xString",;;+
dll.call("MultiByteToWideChar|ui ui s i x i",;;+
0,0,sString,-1,"xString",0))
win.debug(xString,binary.dump("xString"),binary.length("xString"))
quit
----------------------------------------------------------------------
Then,
xString: 04 31 31 31 07 01 in hex
(if it were 1-byte header, it should be 04 07 01)
binary.dump("xString"):A\x00\x00\x001111...111 (259 1's, so total 263)
binary.length("xString"): 263
OTOH, I tried also only with binary plugin:
----------------------------------------------------------------------
local bb=repeat(1,271)
binary.from_ascii_string("bb","A")
win.debug(bb,binary.dump("bb"),binary.length("bb"))
quit
----------------------------------------------------------------------
bb: 04 31 31 31 01 in hex
binary.dump("bb"): A
binary.length("bb"): 1
The 4-byte nature is still retained, however, it reports correctly
dump & length in this case. I also tried a long string like 500 in
length. It reprots the correct dump & length too, and moreover, I
didn't have to resize manually the variable bb unlike in dll case.
Sean
Attention: PowerPro's Web site has moved: http://www.ppro.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/