| 50 | } |
| 51 | |
| 52 | int detectParagraphLevel(const char* utf8, const int fallbackLevel, const int maxStrongChars) { |
| 53 | if (!utf8 || maxStrongChars <= 0) return fallbackLevel & 1; |
| 54 | |
| 55 | auto* p = reinterpret_cast<const unsigned char*>(utf8); |
| 56 | int checked = 0; |
| 57 | while (*p) { |
| 58 | const uint32_t cp = utf8NextCodepoint(&p); |
| 59 | if (!cp || cp == REPLACEMENT_GLYPH) break; |
| 60 | |
| 61 | const uchar cls = bidi_class(cp); |
| 62 | if (cls == R || cls == AL) return 1; |
| 63 | if (cls == L) return 0; |
| 64 | checked++; |
| 65 | if (checked >= maxStrongChars) break; |
| 66 | } |
| 67 | |
| 68 | return fallbackLevel & 1; |
| 69 | } |
| 70 | |
| 71 | bool applyBidiVisual(const char* utf8, std::string& out, int paragraphLevel) { |
| 72 | if (!utf8 || !*utf8) return false; |
no test coverage detected