Question

I have the very basic line:

self.label.text = @",הם הכריחו אותה לשתות ויסקי";

Notice the comma at the left of the string. When this displays in a UILabel, I see the comma at the right. This is one example of punctuation problems I am seeing with Hebrew.

Any ideas for resolving this?

Was it helpful?

Solution 2

I've been reading up on Bi-directional text, it seems as though certain Unicode characters specify certain properties of the following text. Through experimentation, I've found that the Right-To-Left Isolate character, or U+2067 ⁧, will cause the text that follows to be displayed in the correct order. So the Objective C solution to the problem was:

self.label.text = [@"\u2067" stringByAppendingString: @",הם הכריחו אותה לשתות ויסקי"];

OTHER TIPS

Most of the text you have is right-to-left, but a comma is left-to-right. You are displaying source code here as it is displayed by Xcode. It's not at all obvious what rules Xcode would choose to display such text. You would be much confident about what your source code is if you write

self.label.text = @"הם הכריחו אותה לשתות ויסקי" ",";

for example or

self.label.text = @"," "הם הכריחו אותה לשתות ויסקי";

so you know 100% sure what text you have in Xcode. After that I'm afraid it's very much a matter of reading the documentation and seeing what you need to do. While characters in text have some ordering, a text field on its own has a text ordering as well. You can have latin text with a bit of hebrew inside, or hebrew (right to left) text with a bit of latin inside, and they will behave differently.

What you describe looks like a left-to-right text field that is used to display some hebrew text, so the overall display order is left to right, but hebrew items inside (not the comma) are displayed right to left. You'd need to change the display order of the text field itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top