|
6 | 6 |
|
7 | 7 | use {Parser, ToCss, BasicParseError};
|
8 | 8 | use std::char;
|
9 |
| -use std::cmp; |
10 | 9 | use std::fmt;
|
11 | 10 | use tokenizer::Token;
|
12 | 11 |
|
@@ -166,32 +165,9 @@ impl fmt::Debug for UnicodeRange {
|
166 | 165 |
|
167 | 166 | impl ToCss for UnicodeRange {
|
168 | 167 | fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
169 |
| - dest.write_str("U+")?; |
170 |
| - |
171 |
| - // How many bits are 0 at the end of start and also 1 at the end of end. |
172 |
| - let bits = cmp::min(self.start.trailing_zeros(), (!self.end).trailing_zeros()); |
173 |
| - |
174 |
| - let question_marks = bits / 4; |
175 |
| - |
176 |
| - // How many lower bits can be represented as question marks |
177 |
| - let bits = question_marks * 4; |
178 |
| - |
179 |
| - let truncated_start = self.start >> bits; |
180 |
| - let truncated_end = self.end >> bits; |
181 |
| - if truncated_start == truncated_end { |
182 |
| - // Bits not covered by question marks are the same in start and end, |
183 |
| - // we can use the question mark syntax. |
184 |
| - if truncated_start != 0 { |
185 |
| - write!(dest, "{:X}", truncated_start)?; |
186 |
| - } |
187 |
| - for _ in 0..question_marks { |
188 |
| - dest.write_str("?")?; |
189 |
| - } |
190 |
| - } else { |
191 |
| - write!(dest, "{:X}", self.start)?; |
192 |
| - if self.end != self.start { |
193 |
| - write!(dest, "-{:X}", self.end)?; |
194 |
| - } |
| 168 | + write!(dest, "U+{:X}", self.start)?; |
| 169 | + if self.end != self.start { |
| 170 | + write!(dest, "-{:X}", self.end)?; |
195 | 171 | }
|
196 | 172 | Ok(())
|
197 | 173 | }
|
|
0 commit comments