Mercurial > projects > dil
diff trunk/src/dil/Unicode.d @ 764:4579e8505d5e
Fixed unittests and removed dil.File.
Fixed Converter.UTF16toUTF8().
Fixed an encode() function in dil.Unicode.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 16 Feb 2008 03:28:39 +0100 |
parents | 00f872d949ea |
children | 5e3ef1b2011c |
line wrap: on
line diff
--- a/trunk/src/dil/Unicode.d Sat Feb 16 01:47:39 2008 +0100 +++ b/trunk/src/dil/Unicode.d Sat Feb 16 03:28:39 2008 +0100 @@ -157,7 +157,7 @@ char[6] b = void; if (c < 0x80) str ~= c; - if (c < 0x800) + else if (c < 0x800) { b[0] = 0xC0 | (c >> 6); b[1] = 0x80 | (c & 0x3F); @@ -211,8 +211,7 @@ if (c < 0x10000) str ~= cast(wchar)c; else - { - // Encode with surrogate pair. + { // Encode with surrogate pair. wchar[2] pair = void; c -= 0x10000; // c' // higher10bits(c') | 0b1101_10xx_xxxx_xxxx @@ -225,7 +224,7 @@ /++ Returns a decoded character from a UTF-16 sequence. - In case of an error in the sequence 0xD800 is returned. + In case of an error in the sequence ERROR_CHAR is returned. Params: str = the UTF-16 sequence. index = where to start from. @@ -243,7 +242,7 @@ { wchar c2 = str[index+1]; if (0xDC00 <= c2 && c2 <= 0xDFFF) - { + { // Decode surrogate pair. // (c - 0xD800) << 10 + 0x10000 -> // (c - 0xD800 + 0x40) << 10 -> c = (c - 0xD7C0) << 10; @@ -257,7 +256,7 @@ /++ Returns a decoded character from a UTF-16 sequence. - In case of an error in the sequence 0xD800 is returned. + In case of an error in the sequence ERROR_CHAR is returned. Params: p = start of the UTF-16 sequence. end = one past the end of the sequence.