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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 String s = m_codec->decode(start, length, flush, m_fatal, sawError); | 99 String s = m_codec->decode(start, length, flush, m_fatal, sawError); |
100 | 100 |
101 if (m_fatal && sawError) { | 101 if (m_fatal && sawError) { |
102 exceptionState.throwTypeError("The encoded data was not valid."); | 102 exceptionState.throwTypeError("The encoded data was not valid."); |
103 return String(); | 103 return String(); |
104 } | 104 } |
105 | 105 |
106 if (!m_ignoreBOM && !m_bomSeen && !s.isEmpty()) { | 106 if (!m_ignoreBOM && !m_bomSeen && !s.isEmpty()) { |
107 m_bomSeen = true; | 107 m_bomSeen = true; |
108 String name(m_encoding.name()); | 108 String name(m_encoding.name()); |
109 if ((name == "UTF-8" || name == "UTF-16LE" || name == "UTF-16BE") && s[0
] == 0xFEFF) | 109 if ((name == "UTF-8" || name == "utf-16le" || name == "utf-16be") && s[0
] == 0xFEFF) |
110 s.remove(0); | 110 s.remove(0); |
111 } | 111 } |
112 | 112 |
113 if (flush) | 113 if (flush) |
114 m_bomSeen = false; | 114 m_bomSeen = false; |
115 | 115 |
116 return s; | 116 return s; |
117 } | 117 } |
118 | 118 |
119 String TextDecoder::decode(ExceptionState& exceptionState) | 119 String TextDecoder::decode(ExceptionState& exceptionState) |
120 { | 120 { |
121 TextDecodeOptions options; | 121 TextDecodeOptions options; |
122 return decode(nullptr, 0, options, exceptionState); | 122 return decode(nullptr, 0, options, exceptionState); |
123 } | 123 } |
124 | 124 |
125 } // namespace blink | 125 } // namespace blink |
OLD | NEW |