Example ICU template displays text differently than Microsoft Notepad and Word

I have bidirectional text

1002 -ابو ماجد الانصاري 

Most editors are notepad ++, notepad, etc. show the text as shown here. But when I get this text processed through the ICU, the number is shifted to the right, then spaces and hyphens, and then Arabic. The ICU layout.exe sample application also shows the number on the right. I changed paragraphlayout.cpp and set all possible reordering modes, but the result is still the same:

See Problem Text here

Can someone help set up the ICU to provide output like other display engines do.

+5
source share
1 answer

If I understand correctly, your text "starts" with a number, followed by a hyphen and text. Notepad and other editors allow you to choose the "direction of writing." If you select from right to left, you will get the same result as your screenshot,

RTL screenshot

If you want to keep the recording direction left-right, you can explicitly set it

 ubidi_setPara(para, "1002 -ابو ماجد الانصاري", ‭25, UBIDI_LTR, NULL, pErrorCode); 

or you can insert the line UNICODE U + 202A ( LEFT-TO-RIGHT EMBEDDING ) into the line, which will apply this direction. If your code is in C ++, you can write something like

 icu::UnicodeString string_to_layout = "\x202a"; string_to_layout += "1002 -ابو ماجد الانصاري"; 

and you cannot use string_to_layout as an input parameter for renderParagraph() (see http://icu-project.org/apiref/icu4c-latest/ubidi_8h.htm ).

+6
source

Source: https://habr.com/ru/post/1273428/


All Articles