digitalmars.D.learn - UTF8 to ANSI (1.0)
- jicman (6/6) Jan 30 2009 Greetings!
- Jarrett Billingsley (11/15) Jan 30 2009 If by "ANSI" you mean the Windows-1252/Latin-1, use
- jicman (3/27) Jan 31 2009 Thanks, Jarrett
Greetings! I have done some research on the digitalmars.com for some d code showing UTF8 to ANSI stuff, and there isn't anything that I can clearly use. Long story short, I have about 600+ files that I need to convert from UTF8 to ANSI. They have different languages characters. I can do open the files with notepad and save them as ANSI, but, I thought that I would write a quick d program to do this. Can anyone point me out to a site or place where I can quickly create this small program? thanks, jose
Jan 30 2009
On Fri, Jan 30, 2009 at 5:56 PM, jicman <cabrera_ _wrc.xerox.com> wrote:Greetings! I have done some research on the digitalmars.com for some d code showing UTF8 to ANSI stuff, and there isn't anything that I can clearly use. Long story short, I have about 600+ files that I need to convert from UTF8 to ANSI. They have different languages characters. I can do open the files with notepad and save them as ANSI, but, I thought that I would write a quick d program to do this. Can anyone point me out to a site or place where I can quickly create this small program?If by "ANSI" you mean the Windows-1252/Latin-1, use std.windows.charset.toMBSz. You can then use std.string.toString to get a char[]. A simple program would look something like: import std.file; import std.windows.charset; import std.string; ... foreach(file; listdir("the_dir")) write("latin_" ~ file, toString(toMBSz(cast(char[])read(file)))); and that will write out a file "latin_<filename>" for each file in the_dir.
Jan 30 2009
Jarrett Billingsley Wrote:On Fri, Jan 30, 2009 at 5:56 PM, jicman <cabrera_ _wrc.xerox.com> wrote:Yes.Greetings! I have done some research on the digitalmars.com for some d code showing UTF8 to ANSI stuff, and there isn't anything that I can clearly use. Long story short, I have about 600+ files that I need to convert from UTF8 to ANSI. They have different languages characters. I can do open the files with notepad and save them as ANSI, but, I thought that I would write a quick d program to do this. Can anyone point me out to a site or place where I can quickly create this small program?If by "ANSI" you mean the Windows-1252/Latin-1, use std.windows.charset.toMBSz.You can then use std.string.toString to get a char[]. A simple program would look something like: import std.file; import std.windows.charset; import std.string; ... foreach(file; listdir("the_dir")) write("latin_" ~ file, toString(toMBSz(cast(char[])read(file)))); and that will write out a file "latin_<filename>" for each file in the_dir.Thanks, Jarrett
Jan 31 2009