lojjic/bidi-js

reorder string to get the result as on the screen

Yuriy1988 opened this issue · 4 comments

Hi, need some help, please.
I'm dealing with combined LTR, RTL strings, with digits, symbols, arabic, latin, etc
I'm wondering is it possible to reorder a string value from the <input dir="rtr"> into a string that is actually displayed in the html element

I mean if I have in input
image
the value of the input is
image

How can I process the input string value to have a string with characters in an order as I see looking at the input

I tried bidi.getReorderedString method and it works cool for such cases:
image
in the case above the result of the method is exactly what i expect

but if I have arabic chars, then arabic characters are reversed after calling bidi.getReorderedString

@Yuriy1988 Did you find the solution for this? I'm facing the same problem.

Would you be able to put together a small HTML+JS test case that reproduces your issue?

Going to close this due to lack of info.

My best guess based on the info provided is that getReorderedString is working properly, but if you try to render that resulting string in HTML, the browser will also apply the Bidi algorithm natively to the characters, resulting in RTL substrings being re-reversed. In other words, rendering a string in HTML is not a good way to determine the actual order of the characters in the string.