Readfile command to read binary file error!

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Readfile command to read binary file error!

Post 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
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Readfile command to read binary file error!

Post by highend »

Don't know where this is coming from, but on my system (german locale), it displays the correct result:
binary.png
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Re: Readfile command to read binary file error!

Post by youtao6256 »

my system is win7,64 bit
01.jpg
To see the attached files, you need to log into the forum.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Readfile command to read binary file error!

Post 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

youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Re: Readfile command to read binary file error!

Post 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
To see the attached files, you need to log into the forum.

youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Re: Readfile command to read binary file error!

Post by youtao6256 »

I am in China, the language environment is windows7 64bit Chinese operating system, windows10 the same as the problem.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Readfile command to read binary file error!

Post by highend »

Please look at this post (viewtopic.php?p=151761#p151761)
and provide the necessary information
One of my scripts helped you out? Please donate via Paypal

youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Re: Readfile command to read binary file error!

Post 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
To see the attached files, you need to log into the forum.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Readfile command to read binary file error!

Post by admin »

Thanks. Fix comes with next beta version.

youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Re: Readfile command to read binary file error!

Post 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
To see the attached files, you need to log into the forum.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Readfile command to read binary file error!

Post 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

youtao6256
Posts: 20
Joined: 21 Aug 2017 06:45

Re: Readfile command to read binary file error!

Post 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
To see the attached files, you need to log into the forum.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Readfile command to read binary file error!

Post 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.

Post Reply