OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } else { | 72 } else { |
73 entries_[c & kMask] = CacheEntry(c, 0); | 73 entries_[c & kMask] = CacheEntry(c, 0); |
74 return 0; | 74 return 0; |
75 } | 75 } |
76 } else { | 76 } else { |
77 return length; | 77 return length; |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 | 81 |
| 82 bool Latin1::NonLatin1CanBeConvertedToLatin1(uint16_t c) { |
| 83 ASSERT(c > Latin1::kMaxChar); |
| 84 switch (c) { |
| 85 case 0x130: |
| 86 case 0x131: |
| 87 case 0x149: |
| 88 case 0x178: |
| 89 case 0x17f: |
| 90 case 0x1f0: |
| 91 case 0x1e96: |
| 92 case 0x1e97: |
| 93 case 0x1e98: |
| 94 case 0x1e99: |
| 95 case 0x1e9a: |
| 96 case 0x1e9e: |
| 97 case 0x212a: |
| 98 case 0x212b: |
| 99 case 0xfb00: |
| 100 case 0xfb01: |
| 101 case 0xfb02: |
| 102 case 0xfb03: |
| 103 case 0xfb04: |
| 104 case 0xfb05: |
| 105 case 0xfb06: |
| 106 return true; |
| 107 } |
| 108 return false; |
| 109 } |
| 110 |
| 111 |
82 unsigned Utf8::Encode(char* str, uchar c, int previous) { | 112 unsigned Utf8::Encode(char* str, uchar c, int previous) { |
83 static const int kMask = ~(1 << 6); | 113 static const int kMask = ~(1 << 6); |
84 if (c <= kMaxOneByteChar) { | 114 if (c <= kMaxOneByteChar) { |
85 str[0] = c; | 115 str[0] = c; |
86 return 1; | 116 return 1; |
87 } else if (c <= kMaxTwoByteChar) { | 117 } else if (c <= kMaxTwoByteChar) { |
88 str[0] = 0xC0 | (c >> 6); | 118 str[0] = 0xC0 | (c >> 6); |
89 str[1] = 0x80 | (c & kMask); | 119 str[1] = 0x80 | (c & kMask); |
90 return 2; | 120 return 2; |
91 } else if (c <= kMaxThreeByteChar) { | 121 } else if (c <= kMaxThreeByteChar) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Copy the rest the slow way. | 210 // Copy the rest the slow way. |
181 WriteUtf16Slow(unbuffered_start_, | 211 WriteUtf16Slow(unbuffered_start_, |
182 data + buffer_length, | 212 data + buffer_length, |
183 length - buffer_length); | 213 length - buffer_length); |
184 return length; | 214 return length; |
185 } | 215 } |
186 | 216 |
187 } // namespace unibrow | 217 } // namespace unibrow |
188 | 218 |
189 #endif // V8_UNICODE_INL_H_ | 219 #endif // V8_UNICODE_INL_H_ |
OLD | NEW |