Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact


Moderators: larsivi kris

Posted: 12/22/08 17:17:58 Modified: 12/22/08 17:22:26

I have got following problem. I need to read text files encoded in ANSI , then convert it to UTF-8 and do something, and then save them as encoded in ANSI.

Author Message

Posted: 12/22/08 20:21:08

I assume you're one Windows, since you're calling it ANSI. The simplest way is probably to use tango.sys.win32.CodePage?. Convert one line at a time if the files can grow big. CodePage? will convert everything twice, using utf-16 as an intermediate format. So it's not the most efficient way.

There's some ICU stuff in Mango, but I'm not familiar with that.

Posted: 12/22/08 21:47:16

load the file into an array, convert it using CodePage?.d (as tohru says), do the processing, use CodePage? to convert the whole array back to a codepage again, and write it out