| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 String s = m_codec->decode(start, length, flush, m_fatal, sawError); | 98 String s = m_codec->decode(start, length, flush, m_fatal, sawError); |
| 99 | 99 |
| 100 if (m_fatal && sawError) { | 100 if (m_fatal && sawError) { |
| 101 exceptionState.throwTypeError("The encoded data was not valid."); | 101 exceptionState.throwTypeError("The encoded data was not valid."); |
| 102 return String(); | 102 return String(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 if (!m_ignoreBOM && !m_bomSeen && !s.isEmpty()) { | 105 if (!m_ignoreBOM && !m_bomSeen && !s.isEmpty()) { |
| 106 m_bomSeen = true; | 106 m_bomSeen = true; |
| 107 String name(m_encoding.name()); | 107 String name(m_encoding.name()); |
| 108 if ((name == "UTF-8" || name == "UTF-16LE" || name == "UTF-16BE") && s[0
] == 0xFEFF) | 108 if ((name == "UTF-8" || name == "utf-16le" || name == "utf-16be") && s[0
] == 0xFEFF) |
| 109 s.remove(0); | 109 s.remove(0); |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (flush) | 112 if (flush) |
| 113 m_bomSeen = false; | 113 m_bomSeen = false; |
| 114 | 114 |
| 115 return s; | 115 return s; |
| 116 } | 116 } |
| 117 | 117 |
| 118 String TextDecoder::decode(ExceptionState& exceptionState) | 118 String TextDecoder::decode(ExceptionState& exceptionState) |
| 119 { | 119 { |
| 120 TextDecodeOptions options; | 120 TextDecodeOptions options; |
| 121 return decode(nullptr, 0, options, exceptionState); | 121 return decode(nullptr, 0, options, exceptionState); |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace blink | 124 } // namespace blink |
| OLD | NEW |