| 32 | namespace BidiUtils { |
| 33 | |
| 34 | bool startsWithRtl(const char* utf8, int maxStrongChars) { |
| 35 | if (!utf8 || maxStrongChars <= 0) return false; |
| 36 | |
| 37 | auto* p = reinterpret_cast<const unsigned char*>(utf8); |
| 38 | int checked = 0; |
| 39 | while (*p) { |
| 40 | const uint32_t cp = utf8NextCodepoint(&p); |
| 41 | if (!cp || cp == REPLACEMENT_GLYPH) break; |
| 42 | |
| 43 | const uchar cls = bidi_class(cp); |
| 44 | if (cls == R || cls == AL) return true; |
| 45 | if (cls == L) return false; |
| 46 | checked++; |
| 47 | if (checked >= maxStrongChars) break; |
| 48 | } |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | int detectParagraphLevel(const char* utf8, const int fallbackLevel, const int maxStrongChars) { |
| 53 | if (!utf8 || maxStrongChars <= 0) return fallbackLevel & 1; |
no test coverage detected