Author Topic: ANSI binary read.  (Read 2177 times)

0 Members and 1 Guest are viewing this topic.

Offline mcampbe

  • Newbie
  • Posts: 1
    • View Profile
ANSI binary read.
« on: September 19, 2021, 11:56:54 pm »
Does anyone know how to do an ansi binary read of a file? From what I can tell I know how to do an ascii binary read of a file by open the file using the Open "example.txt" for Binary as #1 code. As fas as I can tell that is an ascii binary read but I can't seem to do an ansi binary read. Any suggestions?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: ANSI binary read.
« Reply #1 on: September 20, 2021, 12:40:32 am »
When you open for binary, you read 1 ansi character at a time.

ASCII is 7-bit values, for a max of 128 characters.
ANSI is 8-bit values, for a max of 256 characters.

You almost never see true 7-bit ASCII anymore; you always see ANSI files which people just call ASCII as the first 128 characters are an identical match to the ASCII characters.

QB64 works with 8-bit characters (ANSI) and not any compressed 7-bit ASCII.  All you ned to do is simply read a character and you’ll get the 8-bit value back for it.

Where you might be seeing issues is in the codepage your data was encoded in, causing the extended-ascii characters to not display properly, but that’s a different issue from your question completely.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!