Changeset 2190
- Timestamp:
- 11/23/10 11:42:57 (14 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/utf.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r2189 r2190 37 37 $(LI $(BUGZILLA 4445): roundTo!ubyte(255.0) throws) 38 38 $(LI $(BUGZILLA 4638): Regression: new writeln does not recognize "wstring toString") 39 39 $(LI $(BUGZILLA 5053): Better error message for cyclic dependencies.) 40 40 $(LI $(BUGZILLA 5054): Splitter example doesn't work) 41 41 $(LI $(BUGZILLA 5120): ICE(mtype.c) void associative arrays) 42 42 $(LI $(BUGZILLA 5131): Segfault(expression.c) opAssign and associative arrays (AA) are broken for types != this) 43 43 $(LI $(BUGZILLA 5133): dmd fails to build rdmd (problem with startsWith)) 44 44 $(LI $(BUGZILLA 5154): Class Range does not work in writeln) 45 45 $(LI $(BUGZILLA 5163): meaningless error message with front() applied to void[].) 46 46 $(LI $(BUGZILLA 5220): Make std.conv.ConvError an Exception instead of an Error; $(RED deprecated ConvError and ConvOverflowError) with ConvException and ConvOverflowException. Note that any code depending on the fact that these exceptions were Error gets broken.) 47 $(LI $(BUGZILLA 5247): std.utf.stride() should not return 0xFF) 47 48 ) 48 49 ) 49 50 50 51 <div id=version> 51 52 $(UL 52 53 $(NEW 050) 53 54 $(NEW 049) 54 55 $(NEW 048) 55 56 $(NEW 047) 56 57 $(NEW 046) trunk/phobos/std/utf.d
r2189 r2190 128 128 assert(!isValidDchar(cast(dchar)0x00DC00)); 129 129 assert(!isValidDchar(cast(dchar)0x00DFFF)); 130 130 assert(isValidDchar(cast(dchar)0x00FFFE)); 131 131 assert(isValidDchar(cast(dchar)0x00FFFF)); 132 132 assert(isValidDchar(cast(dchar)0x01FFFF)); 133 133 assert(isValidDchar(cast(dchar)0x10FFFF)); 134 134 assert(!isValidDchar(cast(dchar)0x110000)); 135 135 } 136 136 137 137 138 @safe pure nothrow138 @safe pure 139 139 { 140 140 141 141 private immutable ubyte[256] UTF8stride = 142 142 [ 143 143 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 144 144 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 145 145 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 146 146 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 147 147 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 148 148 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, … … 155 155 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 156 156 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 157 157 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 158 158 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF, 159 159 ]; 160 160 161 161 /** 162 162 * stride() returns the length of a UTF-8 sequence starting at index $(D_PARAM i) 163 163 * in string $(D_PARAM s). 164 164 * Returns: 165 * The number of bytes in the UTF-8 sequence or 166 * 0xFF meaning s[i] is not the start of of UTF-8 sequence. 165 * The number of bytes in the UTF-8 sequence. 166 * Throws: 167 * UtfException if s[i] is not the start of the UTF-8 sequence. 167 168 */ 168 169 uint stride(in char[] s, size_t i) 169 170 { 170 return UTF8stride[s[i]]; 171 immutable result = UTF8stride[s[i]]; 172 if (result == 0xFF) 173 throw new UtfException("Not the start of the UTF-8 sequence"); 174 return result; 171 175 } 172 176 173 177 /** 174 178 * stride() returns the length of a UTF-16 sequence starting at index $(D_PARAM i) 175 179 * in string $(D_PARAM s). 176 180 */ 177 uint stride(in wchar[] s, size_t i)181 nothrow uint stride(in wchar[] s, size_t i) 178 182 { 179 183 immutable uint u = s[i]; 180 184 return 1 + (u >= 0xD800 && u <= 0xDBFF); 181 185 } 182 186 183 187 /** 184 188 * stride() returns the length of a UTF-32 sequence starting at index $(D_PARAM i) 185 189 * in string $(D_PARAM s). 186 190 * Returns: The return value will always be 1. 187 191 */ 188 uint stride(in dchar[] s, size_t i)192 nothrow uint stride(in dchar[] s, size_t i) 189 193 { 190 194 return 1; 191 195 } 192 196 193 } // stride functions are @safe , pure and nothrow197 } // stride functions are @safe and pure 194 198 195 199 196 200 @safe pure 197 201 { 198 202 199 203 /******************************************* 200 204 * Given an index $(D_PARAM i) into an array of characters $(D_PARAM s[]), 201 205 * and assuming that index $(D_PARAM i) is at the start of a UTF character, 202 206 * determine the number of UCS characters up to that index $(D_PARAM i). 203 207 */
