Jump to content

..


Recommended Posts

It this intended?

Local $s_File = "D:\Downloads\♥♦♣♠.rar"
Local $b_FileName = StringToBinary($s_File & Chr(0))

I mean, I don't see any StringToBinary() flag use so its used in default ANSI. But at the same time your processing a string(filename) that contains UTF characters.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Ok. Still somewhat mystified.

On your.

The FileWrites clearly show that while $t_ArcNameBuf is Null terminated, $t_ArcNameBufW is not.

I think your making a wrong assumption there. You can't get a [NUL] character back from a DllStruct thats defined with as string-type content like DllStructCreate("wchar[100]").

It will assume the string has ended when it hits that [NUL] byte. Unlike DllStructCreate("byte...) that returns every byte, including the termination [NUL] one.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Seems as I expected.

Local $s1 = "♥♥♥♥♥♥♥♥" ;; same charcter 8 times.
Local $s2 = "♥♦♣♠" ;; your for differant characters.
Local $t1 = DllStructCreate("wchar[8]")
Local $t2 = DllStructCreate("byte[" & DllStructGetSize($t1) & "]",DllStructGetPtr($t1))
DllStructSetData($t1, 1, $s1)
DebugOut('out1', DllStructGetData($t2, 1)) ;### Debug DebugOut.
DllStructSetData($t1, 1, $s2)
DebugOut('out2', DllStructGetData($t2, 1)) ;### Debug DebugOut.
DllStructSetData($t1, 1, $s2 & Chr(0)) ;; Chr(0) == ChrW(0)
DebugOut('out3', DllStructGetData($t2, 1)) ;### Debug DebugOut.
;; output:
;; out1 = 0x65266526652665266526652665266526 {bn}(16) [0,0]
;; out2 = 0x65266626632660260000652665266526 {bn}(16) [0,0] ;; auto terminated with [NUL] terminator.
;; out3 = 0x65266626632660260000000065266526 {bn}(16) [0,0] ;; additional [NUL] added as requested.
(using my own DebugOut() UDF.)

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

It doesn't make sense why you are trying to write NULL characters to an AU3 file. But hey, if you need to write a NULL term or two to a file.. here's one way:

$hFile=FileOpen(@DesktopDir&'\test.bin',32+8+2)
FileWrite($hFile,"A string"&ChrW(0)&"Another string"&ChrW(0))
FileClose($hFile)
Link to comment
Share on other sites

(not at home with utf and such, so no 100% type answers from me here. :graduated: )

If I understand you correctly, then I don't need to manually add a Null character when using a wide-character type (wchar).

In general, that seems to be correct yes.

Anything that accesses that data automatically knows that the data ends with a Null even though the Null character is not a visible part of the string.

With normal use, yes.

I may not be explaining it right but the bottom line is that what I am trying to do here is pointless and unnecessary. I did some more testing of wide-character type reading and this seems to be the case.

In this case, yes, not needed.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...