Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[SOLVED] AHK_L unicode - binary search problem


  • Please log in to reply
2 replies to this topic
wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
In ANSI builds of AHKL it was easy to search for binary sequence of bytes with this simple code
file:=fileOpen("binary.dat","r")
bin:=file.read()
pos:=regExMatch(bin,"\x00\x00\x83\xF9\x02\x75")
It doesn't work as is in unicode build of AHKL, so I've had to use CreateFile + CreateFileMapping + MapViewOfFile + machine code for binary search...

So the question is, how to perform a binary data search in AHKL unicode?

p.s. Another script works in unicode build with regExMatch as is...

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Strings are 16-bit in Unicode builds, so PCRE matches against 16-bit units.
VarSetCapacity(v, 8, 1), NumPut(0x[color=darkred]1020[/color][color=red]3040[/color]00000000, v, 0, "int64")  ; (reversed byte order)
MsgBox % (RegExMatch(v, "\x{[color=red]3040[/color]}\x{[color=darkred]1020[/color]}") - 1) * 2


wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
thanks