Thread overview
D in the future
Sep 14, 2006
Tóth László
Oct 02, 2006
Hasan Aljudy
encodings & utf-8
Oct 04, 2006
Boyko Bantchev
Oct 04, 2006
Josh Stern
Oct 04, 2006
Josh Stern
Oct 05, 2006
Boyko Bantchev
September 14, 2006
D is dead? I found D language from C::B IDE, but the D pages are too old in the internet.


September 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. 
> 
> 

Too old??  The front page is from less than a month ago...  The latest entry in the change log is from just two weeks ago...  No no, we are quite alive and kicking.  Except that this newsgroup ('D') was long ago abandoned.  All discussions are in the 'digitalmars.D[.*]' family.

Listing available here:
http://www.digitalmars.com/NewsGroup.html

-- Chris Nicholson-Sauls
October 02, 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.
October 04, 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
October 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,

Use this web page in your application after swapping the comment token in your edit:


http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT

Then D has std libs to concast unsigned 32 bit unicode values to utf8 byte string reps (e.g. look in std.utf8)

The utf8 encoding is explained here (simple enough to write your own
function if you wanted to):

http://www.cl.cam.ac.uk/~mgk25/unicode.html


October 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,
> 
> Use this web page in your application after swapping the comment token in your edit:
> 
> 
> http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT
> 
> Then D has std libs to concast unsigned 32 bit unicode values to utf8 byte string reps (e.g. look in std.utf8)
> 
> The utf8 encoding is explained here (simple enough to write your own
> function if you wanted to):
> 
> http://www.cl.cam.ac.uk/~mgk25/unicode.html

October 05, 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;
   }