Just asking in case there is a positive answer out there.
I want to add a UTF8 text file in the lines of code, so I don’t have to load a separate text file.
I know I cannot use EncodeBase64 to encode this, but am just wondering if there’s another way?
Drag the file into the navigator. You can then reference the file as a string in code.
Can you post some simple code?
My mind isn’t finding anything clear.
You dont need code.
Create a file called mystuff.txt
Fill it with UTF8 text and save
Drag it into your open project, and it will appear as part of the project explorer, looking like a module or a window or a class.
It will be called mystuff (no .txt)
You can use it like a string constant
var s as string
s = mystuff
But because it is a constant, you cannot say
mystuff = “Apple”
Thanks. I didn’t think I could do that.
So just this
var s as string
s = mystuff
Wow.
What other file types does it work with. I already know about pictures.
Well, xojo is kind of dumb for encodings, your example code is wrong, the text is going to have an “undefined” encoding.
NO, if you use “just” that, it is going to treat your text as ascii only. You have to tell xojo that the text is UTF8
var s as string
s = mystuff
s = s.DefineEncoding(Encodings.UTF8)
Aah. I knew couldn"t be that simple.
TY
What other file types does it work with?
I already know about pictures.
On a Mac, you can drag in plist files and they are merged with the one that the IDE builds.
Sounds are handled specially too.
Depending on what you are trying to “achieve” with
I want to add a UTF8 text file in the lines of code
But something that you can do if you want some static UTF8 text to be available is to just create a string constant. These constants can contain a lot of text.
In the IDE, just paste your UTF8 text file into the constant that you are creating.
Then the contents of that constant are available to be referenced in your code.
This is process I decided to use, and I didn’t have to mess with encoding. It took it just as it was, and the array loaded properly.
Thankyou all