-[UITextView positionFromPosition:offset:] positions are shifted by U+200C
| Originator: | nicolas | ||
| Number: | rdar://11019495 | Date Originated: | 2012-03-09 |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | 5.1 (9B176) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
After inserting Zero-width non-joiner (character U+200C, abbreviated ZWNJ) in the contents of a UITextView, the text positions returned by -[UITextView positionFromPosition:offset:] are shifted.
Steps to Reproduce:
UITextView *textView = [UITextView new];
textView.text = @"Auf\u200clage";
NSInteger expectedOffset = 5; // index of 'a'
UITextPosition *beginning = [textView beginningOfDocument];
UITextPosition *position = [textView positionFromPosition:beginning offset:expectedOffset];
NSInteger actualOffset = [textView offsetFromPosition:beginning toPosition:position];
NSAssert(expectedOffset == actualOffset, @"Actual offset (%d) != Expected offset (%d)", actualOffset, expectedOffset);
Expected Results:
The variable expectedOffset and actualOffset should be equal.
Actual Results:
The variable actualOffset is equal to 6. The assertion fails.
Regression:
The bug occurs only when a ZWNJ character is located between the source position and the character at the provided offset.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!