|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - D in the future
D is dead? I found D language from C::B IDE, but the D pages are too old in the internet. Sep 14 2006
Tóth László wrote:D is dead? I found D language from C::B IDE, but the D pages are too old in the internet. Sep 14 2006
no, check the change log, and, get a newsreader client and checkout the Digitalmars.D newsgroup .. not this one, because it's um .. how do you say it? deprecated. Oct 02 2006
Hello! I need to read & write text files in cyrillic encoding, cp1251, on Windows. How can I do that? Are there library functions that could transform strings between specific, byte-for-byte encodings, such as cp1251, and utf-8? I tried to find such in Phobos, but couldn't. Thanks, Boyko Oct 04 2006
On Wed, 04 Oct 2006 13:00:51 +0000, Boyko Bantchev wrote:Hello! I need to read & write text files in cyrillic encoding, cp1251, on Windows. How can I do that? Are there library functions that could transform strings between specific, byte-for-byte encodings, such as cp1251, and utf-8? I tried to find such in Phobos, but couldn't. Thanks, Oct 04 2006
I should add that D also has the import std.c.wcharh and the C function mbsrtowcs() and related may already do what you want for the first part of the mapping (cyrillic encoding to unicode). On Wed, 04 Oct 2006 12:58:44 -0500, Josh Stern wrote:On Wed, 04 Oct 2006 13:00:51 +0000, Boyko Bantchev wrote:Hello! I need to read & write text files in cyrillic encoding, cp1251, on Windows. How can I do that? Are there library functions that could transform strings between specific, byte-for-byte encodings, such as cp1251, and utf-8? I tried to find such in Phobos, but couldn't. Thanks, Oct 04 2006
Thanks, Josh!
I've found the following to work for me:
1) read through getchar(), write through putchar()
(wrapping each one in to work at string/line level) --
so the cp1251-encoded text goes in and out untouched;
2) to transform constant cyrillic strings (which in the program
source are utf-8) for output in cp1251, I use the following
(which must be slightly modified if the strings are mixed
cyrillic/latin):
char[] UTF8to1251(char[] s) {
int n = s.length;
char[] d;
for (uint i=0; i<n;)
d ~= decode(s,i)-(1040-192);
return d;
}
Oct 04 2006
|