Hey all. Doing some work for a client and there was a problem with a specific code being put into each document. It needs to be popped. I can do that myself.
What I need to know is whether or not a string saved from a loaded file (using print #x) will screw with the UTF-8 encoding.
UTF-8
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
Re: UTF-8
If you're talking here about writing non-ASCII characters to a text file, then you shouldn't have a problem provided that:
* you specify the "utf8" encoding when opening the file
* you print a wstring to the file
For example, the following works fine on my machine:
If you're not using a wstring but an ascii string, then you might still be able to get way with it if the unicode characters you want to print have code points of less than 256. In this example, by knowing that the '£' sign has a unicode value of 163 I was able to print it successfully to a utf-8 file:
Hope this helps.
* you specify the "utf8" encoding when opening the file
* you print a wstring to the file
For example, the following works fine on my machine:
Code: Select all
dim w as wstring*8 = "€123.45"
open "output2.txt" for output encoding "utf8" as #1
print #1, w
close #1
Code: Select all
dim a as string = chr(163) + "123.45"
open "output2.txt" for output encoding "utf8" as #1
print #1, a
close #1
-
- Posts: 2655
- Joined: Aug 28, 2008 10:54
- Location: new york
Re: UTF-8
Thanks.