WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mueer01 on August 22, 2016, 12:50:57 AM

Title: How to replace HEX 001A in a file?
Post by: mueer01 on August 22, 2016, 12:50:57 AM
Hello,

how can I replace the SUB char 001A in a file, using BinaryReplace? I tried
...
BinaryReplace( binbuf, "\u001a", " ", @TRUE)
and
BinaryReplace( binbuf, "^Z", " ", @TRUE)
...
but it does not replace it.
And using this char directly in the command returns a syntax error.

Regards,
Erhard

Title: Re: How to replace HEX 001A in a file?
Post by: td on August 22, 2016, 06:49:34 AM
A Unicode version of BinaryReplace was never implemented for some reason but the alternative is relatively simple:

Code (winbatch) Select
nOffset = BinaryIndexBin(hBin, 0,'00A1',@fwdscan, 1)
BinaryPokeHex(hBin,nOffset, '0020')

; Or this will work instead of BinaryPokeHex.
;BinaryPokeStrW(hBin, nOffset, " ", 1)
Title: Re: How to replace HEX 001A in a file?
Post by: mueer01 on August 22, 2016, 07:27:36 AM
YEPP, it works. (But have to use 1A, not A1)
Many thanks
Title: Re: How to replace HEX 001A in a file?
Post by: td on August 22, 2016, 07:34:12 AM
Quote from: mueer01 on August 22, 2016, 07:27:36 AM
YEPP, it works. (But have to use 1A, not A1)

Well, at least the idea was communicated despite the  stupid dyslexia...