MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / detectParagraphLevel

Function detectParagraphLevel

lib/MiniBidi/BidiUtils.cpp:52–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52int 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
71bool applyBidiVisual(const char* utf8, std::string& out, int paragraphLevel) {
72 if (!utf8 || !*utf8) return false;

Callers 1

renderMethod · 0.85

Calls 2

utf8NextCodepointFunction · 0.85
bidi_classFunction · 0.85

Tested by

no test coverage detected