Text direction with print or println in Swift for mixed text

风流意气都作罢 提交于 2019-12-24 12:43:35

问题


I am attempting to print a string with a hebrew character "א - aleph is a silent..." using println or print functions in Swift. The simple code below has an output with the first character printed right-to-left (RTL) and the rest of the text left-to-right (LTR). How can I change this so it is all printed LTR.

Thanks in advance.

var content:String="\u{05D0} - aleph is a silent consonant - however it is pronounced as a, o, e, i or u based on the vowel used."

println(content)

Output should be:

א - aleph is a silent consonant - however it is pronounced as a, o, e, i or u based on the vowel used.

However the hebrew character is printed on the right of the line.


回答1:


It looks like I found the answer. Adding "\u{200E}", the Left to Right Mark before the character resolves the issue.

More here: http://en.wikipedia.org/wiki/Left-to-right_mark



来源:https://stackoverflow.com/questions/27187417/text-direction-with-print-or-println-in-swift-for-mixed-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!