I am developing chat application. In iOS 8, i am sending text and image, while sending image with text a characters "\\U0000fffc" are prefixed to nsstring.
I tried using the below code,but it is not working
NSCharacterSet *characterset=[NSCharacterSet characterSetWithCharactersInString:@"\\U0000fffc"];
NSString *newString = [str stringByTrimmingCharactersInSet:characterset];
Any help would be appreciated
Thanks to All who have answered and contributed. I fixed using below code
NSString *codeString = @"\uFFFC";
NSString *msg=[msg stringByReplacingOccurrencesOfString:codeString withString:@""];
If I used above code then compiled errors are fixed and worked....!
This is the replacement character (often a black diamond with a white question mark or an empty square box) is a symbol found in the Unicode standard at codepoint U+FFFD in the Specials table. It is used to indicate problems when a system is unable to render a stream of data to a correct symbol. It is usually seen when the data is invalid and does not match any character.
This can be removed as follow
NSString *codeString = @"\\ufffc";
NSString *newString=[str stringByReplacingOccurrencesOfString:codeString withString:@""];
PS : " /uFFFC " didn't worked for me.
NSString *str = @"This is my string \U0000fffc";
NSString *strModified = [str stringByReplacingOccurrencesOfString:@"\U0000fffc" withString:@""];
NSLog(@"%@",strModified);
Try this. Hope will work for you. :)
Today, I have faced the same situation and after digging in some more I have found that the said character is in fact NSAttachmentCharacter
which the function -(void)replaceCharactersInRange:(NSRange)range withAttributedString:(NSAttributedString *)attrString;
adds to your attributed string to mark the position of a NSTextAttachment
in your string and you shouldn't replace it anyways. If you are still facing trouble working with your Strings, provide more information about the problem, otherwise, stick to your current implementation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.