Returns the result of applying the fold f to the rune r.
| 298 | |
| 299 | // Returns the result of applying the fold f to the rune r. |
| 300 | Rune ApplyFold(const CaseFold *f, Rune r) { |
| 301 | switch (f->delta) { |
| 302 | default: |
| 303 | return r + f->delta; |
| 304 | |
| 305 | case EvenOddSkip: // even <-> odd but only applies to every other |
| 306 | if ((r - f->lo) % 2) |
| 307 | return r; |
| 308 | FALLTHROUGH_INTENDED; |
| 309 | case EvenOdd: // even <-> odd |
| 310 | if (r%2 == 0) |
| 311 | return r + 1; |
| 312 | return r - 1; |
| 313 | |
| 314 | case OddEvenSkip: // odd <-> even but only applies to every other |
| 315 | if ((r - f->lo) % 2) |
| 316 | return r; |
| 317 | FALLTHROUGH_INTENDED; |
| 318 | case OddEven: // odd <-> even |
| 319 | if (r%2 == 1) |
| 320 | return r + 1; |
| 321 | return r - 1; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | // Returns the next Rune in r's folding cycle (see unicode_casefold.h). |
| 326 | // Examples: |
no outgoing calls
no test coverage detected