Page 1 of 1

Chr(0) = nothing? So I have a problem.

Posted: Thu Nov 11, 2021 8:29 pm
by Marcos.exe
Hi!
I need to create a file that writes a string.
Would be:

WriteString(#file, Chr(0)+Chr(0)+Chr(0)+Chr(6))

When the file is opened, the result is just "♠"
building in another language, I get " ♠"
But I need to build for the web, and I'm trying to do it in SB.
In PureBasic the result is the same.
I tried to save the file with various encoding types, but nothing.
Does anyone know how to do this?

Re: Chr(0) = nothing? So I have a problem.

Posted: Thu Nov 11, 2021 8:54 pm
by plouf
using POKEB

Code: Select all

  Procedure Callback(Status, Filename$, File, SizeRead)
    Select Status
      Case #PB_Status_Saved
        ; File correctly saved
        
      Case #PB_Status_Error
        ; File saving has failed
    EndSelect
  EndProcedure

CreateFile(0, "dataFile.hex", @Callback()) 

*Buffer = AllocateMemory(4)
PokeB(*Buffer,0,0)
PokeB(*Buffer,1,0)
PokeB(*Buffer,2,0)
PokeB(*Buffer,3,6)

WriteData(0,*Buffer,0,4)

ExportFile(0, "text/plain")

Re: Chr(0) = nothing? So I have a problem.

Posted: Thu Nov 11, 2021 9:32 pm
by Marcos.exe
It works perfectly! A problem eliminated.
Thank you very much for the solution and speed!