Method: Mail::Multibyte::Unicode#reorder_characters
- Defined in:
- lib/mail/multibyte/unicode.rb
#reorder_characters(codepoints) ⇒ Object
Re-order codepoints so the string becomes canonical.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/mail/multibyte/unicode.rb', line 147 def reorder_characters(codepoints) length = codepoints.length- 1 pos = 0 while pos < length do cp1, cp2 = database.codepoints[codepoints[pos]], database.codepoints[codepoints[pos+1]] if (cp1.combining_class > cp2.combining_class) && (cp2.combining_class > 0) codepoints[pos..pos+1] = cp2.code, cp1.code pos += (pos > 0 ? -1 : 1) else pos += 1 end end codepoints end |