-1

I download html file with my app and noticed for a lot of :

\u0026

I search the net and noticed that in equal to : &

So i try to replace it to & with :

newStr = [newStr stringByReplacingOccurrencesOfString:@"/u0026" withString:@"&"];

But all the \u0026 are in the string and won't replace. Any idea why it happen?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
YosiFZ
  • 7,792
  • 21
  • 114
  • 221

2 Answers2

2

What you really need to be using here is CFStringTransform() That Core Foundation function is going to come in real hand for anybody trying to convert to and from escaped forms.

uchuugaka
  • 12,679
  • 6
  • 37
  • 55
0

If you want to replace the substring \u0026 then you need:

newStr = [newStr stringByReplacingOccurrencesOfString:@"\\u0026" withString:@"&"];

Note there needs to be two backslashes.

rmaddy
  • 314,917
  • 42
  • 532
  • 579