Page 1 of 1

Readfile command to read binary file error!

Posted: 21 Aug 2017 08:37
by youtao6256
I would like to use readfile (, "b", 20, 25) command to read the wav file 25,26 bytes of hexadecimal data, but found that the command read the hexadecimal data and source files of the ten Hexadecimal data is not the same? The source file data is 0xAC44, but the incoming data bits 0x3F44, using the pattern “b” or “t” are not correct.

Source file hexadecimal,the wav file 25,26 bytes of hexadecimal data is 0xAC44
02.jpg

script:text hexdump (readfile(, "b",20, ,25),,"b"),1,);
03.jpg

The result of the readfile command. 25,26 bytes of hexadecimal data is 0x3F44
04.jpg

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 09:13
by highend
Don't know where this is coming from, but on my system (german locale), it displays the correct result:
binary.png

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 09:18
by youtao6256
my system is win7,64 bit
01.jpg

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 10:36
by admin
1) Do you see the correct values when you view the file with command File | Quick File View (Ctrl+Q)?

2) What is your locale? Please show this section from Help | Various Information:

Code: Select all

System Locale ID: 1031 (de-DE)
Thread Locale ID: 1031 (de-DE)
Default ANSI Code Page: 1252  (ANSI - Lateinisch I)
Active ANSI Code Page: 1252  (ANSI - Lateinisch I)
Default OEM code page: 850   (OEM - Multilingual Lateinisch I)
Active OEM Code Page: 850   (OEM - Multilingual Lateinisch I)
Is DBCS Code Page: No

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 10:50
by youtao6256
I know that this bug related to the system area, when the system format is set to Chinese, read the data wrong, set the format for the United States is correct, I am a Chinese user, hoping to solve this problem.
05.jpg

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 10:55
by youtao6256
I am in China, the language environment is windows7 64bit Chinese operating system, windows10 the same as the problem.

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 11:02
by highend
Please look at this post (viewtopic.php?p=151761#p151761)
and provide the necessary information

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 11:15
by youtao6256
System Locale ID: 2052 (zh-CN)
Thread Locale ID: 2052 (zh-CN)
Default ANSI Code Page: 936 (ANSI/OEM - 简体中文 GBK)
Active ANSI Code Page: 936 (ANSI/OEM - 简体中文 GBK)
Default OEM code page: 936 (ANSI/OEM - 简体中文 GBK)
Active OEM Code Page: 936 (ANSI/OEM - 简体中文 GBK)
Is DBCS Code Page: Yes

Quick File View (Ctrl+Q)
06.jpg

Re: Readfile command to read binary file error!

Posted: 21 Aug 2017 13:22
by admin
Thanks. Fix comes with next beta version.

Re: Readfile command to read binary file error!

Posted: 26 Aug 2017 15:27
by youtao6256
Hi, I have been updated to 18.20.0300 But how does the readfile command read errors?

script:text hexdump (readfile(, "b",50, ,1),,"b"),1,);
002.JPG
Look at the location of 18h, 0xAC44 or become 0x3F44
001.JPG
Quick View Information (ctrl + Q)
003.JPG
004.JPG
Wav file
voice00110k16bit.rar

Re: Readfile command to read binary file error!

Posted: 26 Aug 2017 20:35
by admin
You should use the new "r" mode (r = raw bytes, binary safe, no conversion):

Code: Select all

text hexdump(readfile( , "r", 50), , "b");  //you see the true bytes

Re: Readfile command to read binary file error!

Posted: 27 Aug 2017 03:36
by youtao6256
Thank you very much for your help, this is indeed the case, I hope you can update the script command help, there are only "t" and "b" mode.
001.JPG
But I used the writefile command encountered problems, trouble to help me see where I use the wrong!

script:writefile("test-out.txt", readfile(, "r"),,"r");
File size and data are problematic!
002.JPG
003.JPG
script:writefile("test-out.txt", readfile(, "r"),,"b");
File size and data are problematic!
004.JPG
005.JPG

Re: Readfile command to read binary file error!

Posted: 27 Aug 2017 12:31
by admin
You are right, the fix was not complete. Next version should have it all. Then you can do either of these:

Code: Select all

writefile("test-out.txt", readfile(, "r"), , "r");

Code: Select all

writefile("test-out.txt", readfile(, "ru"), , "ru");
The help file us updated with each bigger release.