Reputation: 6164
In my iPhone App I have load .html file in uiwebview, when I am highlighting below text
1. The income statement.
with code
NSString *selection = [self.wvNotes stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
In log it gives me text as
1.\u00a0\u00a0\u00a0\u00a0\u00a0 The income statement.
It is replacing space with some \u00a0
. what could be wrong?
Upvotes: 1
Views: 702
Reputation: 11537
NSString *selection = [self.wvNotes stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
is giving you a string that is encoded in unicode. As you have seen if you do an NSLog on this string it will print the non breaking space (.
for the unicode string \u00a0
). If you don't want those you can replace the unicode string with the space string " "
NSString* stringToConvert = @"1.\u00a0\u00a0\u00a0\u00a0\u00a0 Test";
stringToConvert = [stringToConvert stringByReplacingOccurrencesOfString:@"\u00a0" withString:@" "];
// This will print "1. Test"
NSLog(stringToConvert);
Upvotes: 1