Ticket #1610: stxt-fix-nullbytes.patch
File stxt-fix-nullbytes.patch, 1.2 KB (added by , 16 years ago) |
---|
-
src/add-ons/translators/stxt/STXTTranslator.cpp
214 214 * the text converted into one-my_unichar-per-character Unicode in 215 215 * ubuf, and the number of characters converted in ulen. 216 216 */ 217 if (looks_ascii(buf, nbytes, ubuf, &ulen)) { 217 if (nbytes == 0) 218 { 219 code = "UTF-8 Unicode"; 220 encoding = NULL; // "UTF-8"; 221 type = "text"; 222 rv = 1; 223 } else if (looks_ascii(buf, nbytes, ubuf, &ulen)) { 218 224 code = "ASCII"; 219 225 encoding = NULL; //"us-ascii"; 220 226 type = "text"; 221 227 if (nbytes == 1) 222 228 rv = 1; 223 } else if ( nbytes == 0 ||looks_utf8(buf, nbytes, ubuf, &ulen)) {229 } else if (looks_utf8(buf, nbytes, ubuf, &ulen)) { 224 230 code = "UTF-8 Unicode"; 225 231 encoding = NULL; // "UTF-8"; 226 232 type = "text"; 227 if (nbytes == 0) {228 // this is also the Haiku default encoding229 // in case we have an empty buffer230 rv = 1;231 }232 233 } else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen)) != 0) { 233 234 if (i == 1) { 234 235 code = "Little-endian UTF-16 Unicode";