How to detect where there is a right-to-left mark in a UTF-8 string, Pyhton

Viewed 30

I have a UTF-8 string and I want to detect if the bracket in the string is RTL or LTR (to understand if it's an opening or closing bracket) I tried to print the characters - each one on a separate line, and if there is a right-to-left mark, print something like "---RLM---".

I am guessing I need to use encode/decode but I don't understand how to do that for that purpose...

for char in text:
    print(char+'\n')
    if is_right_to_left_mark(char):
        print("right_to_left_mark"+'\n')
    elif is_left_to_right_mark(char):
        print("left_to_right_mark"+'\n')
0 Answers
Related