Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SHELL creates unicode file, can't read correctly with LINE INPUT
#1
Hi, 

I have this snippet to get the number of processor cores.
Problem is that the SHELL command produces a unicode text file and LINE INPUT is not able to read the text correctly.
Manually converting tmp.txt to an ascii file solves the problem.
Question is why is the file created as unicode by default?
Can I influence this from within QB64?
OS is Win 11.
Btw.: I tried also OPEN ... FOR BINARY - doesn't change anything (e.g. LINE INPUT still can't read UNICODE as text):

Code: (Select All)
    returncode% = SHELL("wmic cpu get NumberOfCores >tmp.txt")
   
    IF _FILEEXISTS("tmp.txt") THEN
        OPEN "tmp.txt" FOR INPUT AS #1
            DO UNTIL EOF(1)
                LINE INPUT #1, a$
                ?">";a$;"<";filecount%;",len=";len(a$)
                filecount% = filecount% + 1
            LOOP
        CLOSE #1
    END IF

    'KILL "tmp.txt"
Reply


Messages In This Thread
SHELL creates unicode file, can't read correctly with LINE INPUT - by thesolarcode - 05-05-2023, 10:39 PM



Users browsing this thread: 3 Guest(s)