ios - Way to detect character that takes up more than one index spot in an NSString? -
I'm thinking, is there a character that takes more than 1 index spot in an NSSTing? (Like an emoji). I am trying to implement a custom text view and when the user is removed, I have to know that I should only delete the last index spot or more.
Actually use NSString
to use UTF-16
. Therefore it is very difficult to work with those letters which are two UTF-16 chatter (uniter) or more
. But what you can do to get the range and delete with rangeOfComposedCharacterSequenceAtIndex
.
Find the last character index from the first string
NSUnitor's last chic index = [String length] - 1;
More than the limit of the previous character
NSCNA Last Funeral = [REC limit: Sensitive SuratAntx: Last Customer Index];
Delete the character with the range (if it deletes UTF-16, then two UTF-16 is)
deleted LstCharString = [Str substringToIndex: lastCharRange. Location];
You can use this method with any type of character
, which will deny any number
Comments
Post a Comment