Changeset 402 for trunk/phobos/std/windows/charset.d
- Timestamp:
- 10/15/07 01:42:59 (17 years ago)
- Files:
-
- trunk/phobos/std/windows/charset.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phobos/std/windows/charset.d
r295 r402 36 36 * s = UTF-8 string to convert. 37 37 * codePage = is the number of the target codepage, or 38 38 * 0 - ANSI, 39 39 * 1 - OEM, 40 40 * 2 - Mac 41 41 * 42 42 * Authors: 43 43 * yaneurao, Walter Bright, Stewart Gordon 44 44 */ 45 45 46 const(char *) toMBSz(const char[]s, uint codePage = 0)46 const(char)* toMBSz(string s, uint codePage = 0) 47 47 { 48 48 // Only need to do this if any chars have the high bit set 49 49 foreach (char c; s) 50 50 { 51 51 if (c >= 0x80) 52 52 { 53 53 char[] result; 54 54 int readLen; 55 55 auto ws = std.utf.toUTF16z(s); 56 56 result.length = WideCharToMultiByte(codePage, 0, ws, -1, null, 0, … … 81 81 * 82 82 * Params: 83 83 * s = UTF-8 string to convert. 84 84 * codePage = is the number of the source codepage, or 85 85 * 0 - ANSI, 86 86 * 1 - OEM, 87 87 * 2 - Mac 88 88 * Authors: Stewart Gordon, Walter Bright 89 89 */ 90 90 91 const(char[]) fromMBSz(const char* s, int codePage = 0)91 string fromMBSz(invariant(char)* s, int codePage = 0) 92 92 { 93 const(char *)c;93 const(char)* c; 94 94 95 95 for (c = s; *c != 0; c++) 96 96 { 97 97 if (*c >= 0x80) 98 98 { 99 99 wchar[] result; 100 100 int readLen; 101 101 102 102 result.length = MultiByteToWideChar(codePage, 0, s, -1, null, 0); 103 103
