Module: Coder::Cleaner::Simple::Encodings::UTF_8
Overview
Note: This currently does not remove most overlong forms
Instance Method Summary collapse
- #garbage?(input, buffered) ⇒ Boolean
- #multibyte?(input, buffered) ⇒ Boolean
- #multibyte_body?(input, buffered) ⇒ Boolean
- #multibyte_size(input, buffered) ⇒ Object
- #multibyte_start?(input, buffered) ⇒ Boolean
- #single_byte?(input, buffered) ⇒ Boolean
Instance Method Details
#garbage?(input, buffered) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/coder/cleaner/simple/encodings.rb', line 9 def garbage?(input, buffered) return true if input > 244 or input == 192 or input == 193 case buffered <=> [244, 143, 191] when -1 then false when 0 then input < 192 when 1 then true end end |
#multibyte?(input, buffered) ⇒ Boolean
22 23 24 |
# File 'lib/coder/cleaner/simple/encodings.rb', line 22 def multibyte?(input, buffered) input.between? 128, 244 end |
#multibyte_body?(input, buffered) ⇒ Boolean
30 31 32 |
# File 'lib/coder/cleaner/simple/encodings.rb', line 30 def multibyte_body?(input, buffered) input.between? 128, 191 end |
#multibyte_size(input, buffered) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/coder/cleaner/simple/encodings.rb', line 34 def multibyte_size(input, buffered) case input when 192..223 then 2 when 224..239 then 3 when 240..247 then 4 when 248..244 then 5 when 001..127 then 1 else 0 end end |
#multibyte_start?(input, buffered) ⇒ Boolean
26 27 28 |
# File 'lib/coder/cleaner/simple/encodings.rb', line 26 def multibyte_start?(input, buffered) input.between? 192, 244 end |
#single_byte?(input, buffered) ⇒ Boolean
18 19 20 |
# File 'lib/coder/cleaner/simple/encodings.rb', line 18 def single_byte?(input, buffered) input.between? 1, 127 end |