alper_k
alper_k

Reputation: 512

Remove characters from string iOS

I have an XML which I am using to parse news. News have a description. I'm using NSString to show that description in UILabel.

But, the description comes like this:

Bad news for Windows’ the researches show that Windows’ for years....

And it is being showed with those unwanted characters in UILabel. The numbers are changing in every string. They are not the sames.

I want to remove the characters that begins with &# and the numbers that follow. How can I do that? Which string encoding format should I use?

Thanks a lot.

EDIT: I don't have just one string. If I remove &#8217 from this one, there might be &#7610 in another one. It won't be removed.

I can remove &# characters and numbers too. But when I do that, In a string like that "In 1980, Jobs told us to&#2540 do something" the output will be "In , Jobs told us to do something" 1980 will be gone too, but I don't want that. That's a problem either.

Upvotes: 3

Views: 1609

Answers (1)

Ishu
Ishu

Reputation: 12787

These are ASCAII symbols so you need to use utf-8 string.check this link

so use this line of code

NSString *resultString = [NSString stringWithUTF8String:myAsciiString];

Upvotes: 2

Related Questions