Page 1 of 1
Storing text files inside executables
Posted: Tue Dec 10, 2024 9:36 pm
by Quin
I'm a big fan of embedding data in DataSections in order to avoid shipping a bunch of files around. I currently do this for sounds and JSON, with CatchSound and CatchJSON. However, now I want to store a plane text file inside my app. I can do it just fine like I always do, with two labels in a DataSection with an IncludeBinary nested between them, but I can't figure out how to read it. I've tried PeekS(?Label, ?EndLabel - ?Label) as well as Restore Label Read.s MyValue$, but both produce weird binary output and aren't what I want. Is this possible?
Thanks.
Re: Storing text files inside executables
Posted: Tue Dec 10, 2024 9:45 pm
by infratec
No code no help.
Hint:
Have you used #PB_UTF8 flag inside of PeekS()?
Or is the text file really in unicode?
Re: Storing text files inside executables
Posted: Tue Dec 10, 2024 9:48 pm
by infratec
Code: Select all
DataSection
Start:
IncludeBinary #PB_Compiler_Home + "Examples\Sources\Date.pb"
Stop:
EndDataSection
Debug PeekS(?Start, ?Stop - ?Start, #PB_UTF8|#PB_ByteLength)
Re: Storing text files inside executables
Posted: Tue Dec 10, 2024 10:35 pm
by Quin
infratec wrote: Tue Dec 10, 2024 9:48 pm
Code: Select all
DataSection
Start:
IncludeBinary #PB_Compiler_Home + "Examples\Sources\Date.pb"
Stop:
EndDataSection
Debug PeekS(?Start, ?Stop - ?Start, #PB_UTF8)
Yup, you got it. It was the missing #PB_UTF8 flag.

Re: Storing text files inside executables
Posted: Tue Dec 10, 2024 11:08 pm
by HeX0R
Don't forget #PB_ByteLength
Re: Storing text files inside executables
Posted: Wed Dec 11, 2024 7:52 am
by infratec
You are right.
Corrected my example above.
And you have also to check for a BOM.
Re: Storing text files inside executables
Posted: Wed Dec 11, 2024 11:17 am
by mk-soft
Work without len ...
Code: Select all
DataSection
Start:
IncludeBinary #PB_Compiler_Home + "Examples\Sources\Date.pb"
Data.w 0 ; End
EndDataSection
Debug PeekS(?Start, -1, #PB_UTF8)