0
let brokenString = "Vatanım Sensin 12. Bölüm Fragmanı yayında!"

This is an example of string with decimal code characters.

ö is equal to character 'ö'

ü is equal to character 'ü'

How do I convert that string to: "Vatanım Sensin 12. Bölüm Fragmanı yayında!"

Edit: I also have same problem in Android, so added java tag.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
The Cook
  • 1,403
  • 3
  • 17
  • 33

1 Answers1

0

I believe that this will work:

- (NSString *) format: (NSString *)string {
     NSAttributedString *formattedString = [[NSAttributedString alloc] initWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];
     return formattedString.string;
}

source: here

Jon Rose
  • 8,373
  • 1
  • 30
  • 36
  • I'm afraid that the only advantage of this solution is that it's a one-liner. There are other solutions on SO, give them a try. – werediver Jan 16 '17 at 13:24