Just starting out? Need help? Post your questions and find answers here.
rndrei
Enthusiast
Posts: 151 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 21, 2025 1:16 pm
Why is it withdrawing some strange icons? Hieroglyphs!
Code: Select all
#FILE=1
Define hex_char.c, s.s
If ReadFile(#FILE, "hello.run",#PB_Ascii)
While Eof(#FILE) = 0
hex_char=ReadCharacter(#FILE, #PB_Ascii)
s=Chr(hex_char)
Debug("CHAR=="+s)
Wend
CloseFile(#FILE)
MessageRequester("Information", "cound not read file")
EndIf
Last edited by
rndrei on Mon Apr 21, 2025 1:23 pm, edited 1 time in total.
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 1:23 pm
Your MessageRequester is at the wrong place.
How can we know what is inside of your file?
If you use #PB_ASCII with ReadFile, you don't need it at ReadCharacter again
ReadCharacter converts the ASCII value already to a readable value,
Try this:
Code: Select all
#FILE = 1
Define char.c
If ReadFile(#FILE, "hello.run", #PB_Ascii)
While Not Eof(#FILE)
char = ReadCharacter(#FILE)
Debug "CHAR==" + char
Wend
CloseFile(#FILE)
Else
MessageRequester("Information", "cound not read file")
EndIf
rndrei
Enthusiast
Posts: 151 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 21, 2025 1:32 pm
It displays the number Char == 17791, but in the ASCII tables there are only 255 characters!
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 1:37 pm
Or you meant:
Code: Select all
#FILE = 1
Define UnsignedByte.a
If ReadFile(#FILE, "hello.run", #PB_Ascii)
While Not Eof(#FILE)
UnsignedByte = ReadAsciiCharacter(#FILE)
Debug "HEX==" + RSet(Hex(UnsignedByte), 2, "0") + " CHAR==" + Chr(UnsignedByte)
Wend
CloseFile(#FILE)
Else
MessageRequester("Information", "cound not read file")
EndIf
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 1:39 pm
Show us what is inside of your file.
I, at least, can not know what is inside.
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 1:43 pm
You are right.
This should work:
Code: Select all
#FILE = 1
Define char.c
If ReadFile(#FILE, "hello.run", #PB_Ascii)
While Not Eof(#FILE)
char = ReadCharacter(#FILE, #PB_Ascii)
Debug "HEX==" + RSet(Hex(char), 2, "0") + " CHAR==" + Chr(char)
Wend
CloseFile(#FILE)
Else
MessageRequester("Information", "cound not read file")
EndIf
And PP 6.21b5 has a bug.
ReadCharacter() does not respect #PB_Ascii from ReadDile()
rndrei
Enthusiast
Posts: 151 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 21, 2025 1:53 pm
File - executable Hello.run ELF for Linux. Anyway, some hieroglyphs give out!?
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 1:58 pm
What do you expect
Which character is value 1, 2 or 0x7F?
Use the code table from the Tools section of the IDE to find out.
Or search for ASCII table in a web search engine.
You are reading a binary file and not an ascii file.
rndrei
Enthusiast
Posts: 151 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 21, 2025 2:24 pm
7F must be.But not a hieroglyph!?
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 2:35 pm
https://www.ascii-code.com/
7F is DEL (which means delete) what should it show?
And in your binary file are also values between 0x80 and 0xFF what do you want to see there?
A 'normal' viewer shows a dot for each not printable character. but this is up to you.
In linux use mc, press F3 on the file and show it in hex.
rndrei
Enthusiast
Posts: 151 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Mon Apr 21, 2025 2:54 pm
I understand, I will understand, it probably still depends on the font!?
infratec
Always Here
Posts: 7576 Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany
Post
by infratec » Mon Apr 21, 2025 3:24 pm
No.
A binary file is a binary file. If you want to show it as text, you will always fail.
NicTheQuick
Addict
Posts: 1503 Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:
Post
by NicTheQuick » Mon Apr 21, 2025 6:07 pm
rndrei wrote: Mon Apr 21, 2025 2:54 pm
I understand, I will understand, it probably still depends on the font!?
Yes, it also depends on the font. If the font has printable characters for all of the ASCII codes from 0-255 then you would see something different than these squares with hexadezimal numbers in it. But no usual font as these control characters as valid characters.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
rndrei
Enthusiast
Posts: 151 Joined: Thu Dec 28, 2023 9:04 pm
Post
by rndrei » Fri Apr 25, 2025 11:27 am
NicTheQuick wrote: Mon Apr 21, 2025 6:07 pm
rndrei wrote: Mon Apr 21, 2025 2:54 pm
I understand, I will understand, it probably still depends on the font!?
Yes, it also depends on the font. If the font has printable characters for all of the ASCII codes from 0-255 then you would see something different than these squares with hexadezimal numbers in it. But no usual font as these control characters as valid characters.
I didn’t google, maybe you have such a font?
NicTheQuick
Addict
Posts: 1503 Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:
Post
by NicTheQuick » Fri Apr 25, 2025 11:30 am
rndrei wrote: Fri Apr 25, 2025 11:27 am
I didn’t google, maybe you have such a font?
I don't have such a font and I don't know why I should need one.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.