rtl--increment *bytes in rtl_egc() #1174

dankamongmen/ltr
nick black 3 years ago
parent 61e51043a2
commit d2e39cca85
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -950,10 +950,13 @@ egc_rtl(const char* egc, int* bytes){
}
// insert U+200E, "LEFT-TO-RIGHT MARK". This ought reset the text direction
// after emitting a potentially RTL EGC.
const char LTRMARK[] = "\xe2\x80\x8e";
char* s = (char*)malloc(*bytes + sizeof(LTRMARK)); // cast for C++ callers
memcpy(s, egc, *bytes);
memcpy(s + *bytes, LTRMARK, sizeof(LTRMARK));
const char LTRMARK[] = "\xe2\x80\xad";
char* s = (char*)malloc(*bytes + strlen(LTRMARK) + 1); // cast for C++ callers
memcpy(s, LTRMARK, strlen(LTRMARK));
memcpy(s + strlen(LTRMARK), egc, *bytes);
s[strlen(LTRMARK) + *bytes] = '\0';
//fprintf(stderr, "\nLTR: [%s] (\xe2\x80\xad%s) (%zu) (%d)\n", s, egc, strlen(s), *bytes);
*bytes += strlen(LTRMARK);
return s;
}

@ -20,11 +20,11 @@ TEST_CASE("Bidi") {
uint64_t channels;
auto egc = ncplane_at_yx(n_, 0, 0, &stylemask, &channels);
REQUIRE(nullptr != egc);
CHECK(0 == strcmp(egc, "ה"));
CHECK(0 == strcmp(egc, "\xe2\x80\xadה"));
free(egc);
egc = ncplane_at_yx(n_, 0, 4, &stylemask, &channels);
REQUIRE(nullptr != egc);
CHECK(0 == strcmp(egc, "ך"));
CHECK(0 == strcmp(egc, "\xe2\x80\xadך"));
free(egc);
// FIXME yes, we place this at 0,0 in our internal view...and yet it
// is actually placed at the rightmost cell :/

Loading…
Cancel
Save