On Fri, Jan 11, 2019 at 07:45:05PM +0000, Head Scratcher via Digitalmars-d-learn wrote: > I am using readText to read a file into a string. I am getting a > UTFException on the file. It is probably because the file has an > extended ANSI character that is not UTF-8. > How can I read the file and convert the string into proper UTF-8 in > memory without an exception?
What's the encoding of the file? Without knowing the original encoding, there is no way to get UTF-8 out of it without the risk of some data being lost / garbled. Take a look at std.encoding to see if your file's encoding is already supported. If not, you may have to read the file in binary and do the conversion into UTF-8 yourself. Or use an external program to re-encode your file into UTF-8. On Posix systems, the 'recode' utility will help you do this. T -- To err is human; to forgive is not our policy. -- Samuel Adler