I have a file that has characters that will only be interpreted correctly if the file is read as UTF-8 (characters such as ü). However, it doesn't have the UTF-8 BOM byte header of 0xEF,0xBB,0xBF. The file is created by another program (via PostgreSQL queries requested by my script). When I read the lines from this file, the script doesn't recognize the extended characters correctly, but I have seen that they will be read correctly if the file has the UTF-8 BOM header.
So my question is: Is there a way to force my script to read a file as a UTF-8 file even if it doesn't have the UTF-8 BOM? That would allow me to avoid having to read the file contents and write them back out to a new file with the UTF-8 BOM. I would have to do this for each query that could potentially have these characters in them. Or is that really the only way to do it? It would just be better for performance to limit how much I'm reading and writing files if I could avoid that.
Force a file to be read as UTF-8?
Re: Force a file to be read as UTF-8?
Untested, f := FileOpen(file, "rw", "UTF-8"). See: FileOpen
Re: Force a file to be read as UTF-8?
Thanks. I'll try that.
Re: Force a file to be read as UTF-8?
Perfect! Thanks!
Who is online
Users browsing this forum: Bing [Bot], Recharge, vanheartnet098 and 42 guests