| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 return CString(bytes, resultLength); | 238 return CString(bytes, resultLength); |
| 239 } | 239 } |
| 240 | 240 |
| 241 template <typename CharType> | 241 template <typename CharType> |
| 242 CString TextCodecLatin1::encodeCommon(const CharType* characters, | 242 CString TextCodecLatin1::encodeCommon(const CharType* characters, |
| 243 size_t length, | 243 size_t length, |
| 244 UnencodableHandling handling) { | 244 UnencodableHandling handling) { |
| 245 { | 245 { |
| 246 char* bytes; | 246 char* bytes; |
| 247 CString string = CString::newUninitialized(length, bytes); | 247 CString string = CString::createUninitialized(length, bytes); |
| 248 | 248 |
| 249 // Convert the string a fast way and simultaneously do an efficient check to | 249 // Convert the string a fast way and simultaneously do an efficient check to |
| 250 // see if it's all ASCII. | 250 // see if it's all ASCII. |
| 251 UChar ored = 0; | 251 UChar ored = 0; |
| 252 for (size_t i = 0; i < length; ++i) { | 252 for (size_t i = 0; i < length; ++i) { |
| 253 UChar c = characters[i]; | 253 UChar c = characters[i]; |
| 254 bytes[i] = static_cast<char>(c); | 254 bytes[i] = static_cast<char>(c); |
| 255 ored |= c; | 255 ored |= c; |
| 256 } | 256 } |
| 257 | 257 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 269 return encodeCommon(characters, length, handling); | 269 return encodeCommon(characters, length, handling); |
| 270 } | 270 } |
| 271 | 271 |
| 272 CString TextCodecLatin1::encode(const LChar* characters, | 272 CString TextCodecLatin1::encode(const LChar* characters, |
| 273 size_t length, | 273 size_t length, |
| 274 UnencodableHandling handling) { | 274 UnencodableHandling handling) { |
| 275 return encodeCommon(characters, length, handling); | 275 return encodeCommon(characters, length, handling); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace WTF | 278 } // namespace WTF |
| OLD | NEW |