summaryrefslogtreecommitdiff
path: root/platform/default/bidi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/default/bidi.cpp')
-rw-r--r--platform/default/bidi.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/platform/default/bidi.cpp b/platform/default/bidi.cpp
index f972e43cc1..32a3dc23ef 100644
--- a/platform/default/bidi.cpp
+++ b/platform/default/bidi.cpp
@@ -220,8 +220,13 @@ std::u16string BiDi::getLine(std::size_t start, std::size_t end) {
// UBIDI_DO_MIRRORING: Apply unicode mirroring of characters like parentheses
// UBIDI_REMOVE_BIDI_CONTROLS: Now that all the lines are set, remove control characters so that
// they don't show up on screen (some fonts have glyphs representing them)
- ubidi_writeReordered(impl->bidiLine, mbgl::utf16char_cast<UChar*>(&outputText[0]), outputLength,
- UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS, &errorCode);
+ int32_t finalLength = ubidi_writeReordered(impl->bidiLine,
+ mbgl::utf16char_cast<UChar*>(&outputText[0]),
+ outputLength,
+ UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS,
+ &errorCode);
+
+ outputText.resize(finalLength); // REMOVE_BIDI_CONTROLS may have shrunk the string
if (U_FAILURE(errorCode)) {
throw std::runtime_error(std::string("BiDi::getLine (writeReordered): ") +