Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: Source/wtf/text/TextCodecICU.cpp

Issue 27030014: Remove Backslash-as-JPY hack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: TextCodec/Encoding added Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return; 417 return;
418 } 418 }
419 UCNV_FROM_U_CALLBACK_SUBSTITUTE(context, fromUArgs, codeUnits, length, codeP oint, reason, err); 419 UCNV_FROM_U_CALLBACK_SUBSTITUTE(context, fromUArgs, codeUnits, length, codeP oint, reason, err);
420 } 420 }
421 421
422 class TextCodecInput { 422 class TextCodecInput {
423 public: 423 public:
424 TextCodecInput(const TextEncoding& encoding, const UChar* characters, size_t length) 424 TextCodecInput(const TextEncoding& encoding, const UChar* characters, size_t length)
425 : m_begin(characters) 425 : m_begin(characters)
426 , m_end(characters + length) 426 , m_end(characters + length)
427 { 427 { }
428 if (encoding.hasTrivialDisplayString())
429 return;
430 m_buffer.reserveInitialCapacity(length);
431 m_buffer.append(characters, length);
432 initalizeFromBuffer(encoding);
433 }
434 428
435 TextCodecInput(const TextEncoding& encoding, const LChar* characters, size_t length) 429 TextCodecInput(const TextEncoding& encoding, const LChar* characters, size_t length)
436 { 430 {
437 m_buffer.reserveInitialCapacity(length); 431 m_buffer.reserveInitialCapacity(length);
438 for (size_t i = 0; i < length; ++i) 432 for (size_t i = 0; i < length; ++i)
439 m_buffer.append(characters[i]); 433 m_buffer.append(characters[i]);
440 initalizeFromBuffer(encoding); 434 m_begin = m_buffer.data();
435 m_end = m_begin + m_buffer.size();
441 } 436 }
442 437
443 const UChar* begin() const { return m_begin; } 438 const UChar* begin() const { return m_begin; }
444 const UChar* end() const { return m_end; } 439 const UChar* end() const { return m_end; }
445 440
446 private: 441 private:
447 void initalizeFromBuffer(const TextEncoding& encoding)
448 {
449 // FIXME: We should see if there is "force ASCII range" mode in ICU;
450 // until then, we change the backslash into a yen sign.
451 // Encoding will change the yen sign back into a backslash.
452 encoding.displayBuffer(m_buffer.data(), m_buffer.size());
453 m_begin = m_buffer.data();
454 m_end = m_begin + m_buffer.size();
455 }
456
457 const UChar* m_begin; 442 const UChar* m_begin;
458 const UChar* m_end; 443 const UChar* m_end;
459 Vector<UChar> m_buffer; 444 Vector<UChar> m_buffer;
460 }; 445 };
461 446
462 CString TextCodecICU::encodeInternal(const TextCodecInput& input, UnencodableHan dling handling) 447 CString TextCodecICU::encodeInternal(const TextCodecInput& input, UnencodableHan dling handling)
463 { 448 {
464 const UChar* source = input.begin(); 449 const UChar* source = input.begin();
465 const UChar* end = input.end(); 450 const UChar* end = input.end();
466 451
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 { 504 {
520 return encodeCommon(characters, length, handling); 505 return encodeCommon(characters, length, handling);
521 } 506 }
522 507
523 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable Handling handling) 508 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable Handling handling)
524 { 509 {
525 return encodeCommon(characters, length, handling); 510 return encodeCommon(characters, length, handling);
526 } 511 }
527 512
528 } // namespace WTF 513 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp ('k') | Source/wtf/text/TextEncoding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698