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) { | 82 uint16_t Latin1::ConvertNonLatin1ToLatin1(uint16_t c) { |
83 ASSERT(c > Latin1::kMaxChar); | 83 ASSERT(c > Latin1::kMaxChar); |
84 switch (c) { | 84 switch (c) { |
85 case 0x130: | 85 // This are equivalent characters in unicode. |
86 case 0x131: | 86 case 0x39c: |
87 case 0x149: | 87 case 0x3bc: |
| 88 return 0xb5; |
| 89 // This is an uppercase of a Latin-1 character |
| 90 // outside of Latin-1. |
88 case 0x178: | 91 case 0x178: |
89 case 0x17f: | 92 return 0xff; |
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 } | 93 } |
108 return false; | 94 return 0; |
109 } | 95 } |
110 | 96 |
111 | 97 |
112 unsigned Utf8::Encode(char* str, uchar c, int previous) { | 98 unsigned Utf8::Encode(char* str, uchar c, int previous) { |
113 static const int kMask = ~(1 << 6); | 99 static const int kMask = ~(1 << 6); |
114 if (c <= kMaxOneByteChar) { | 100 if (c <= kMaxOneByteChar) { |
115 str[0] = c; | 101 str[0] = c; |
116 return 1; | 102 return 1; |
117 } else if (c <= kMaxTwoByteChar) { | 103 } else if (c <= kMaxTwoByteChar) { |
118 str[0] = 0xC0 | (c >> 6); | 104 str[0] = 0xC0 | (c >> 6); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Copy the rest the slow way. | 196 // Copy the rest the slow way. |
211 WriteUtf16Slow(unbuffered_start_, | 197 WriteUtf16Slow(unbuffered_start_, |
212 data + buffer_length, | 198 data + buffer_length, |
213 length - buffer_length); | 199 length - buffer_length); |
214 return length; | 200 return length; |
215 } | 201 } |
216 | 202 |
217 } // namespace unibrow | 203 } // namespace unibrow |
218 | 204 |
219 #endif // V8_UNICODE_INL_H_ | 205 #endif // V8_UNICODE_INL_H_ |
OLD | NEW |