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
  • 307,833
  • 40
  • 508
  • 550
The Cook
  • 1,373
  • 2
  • 15
  • 32

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,122
  • 1
  • 27
  • 35
  • 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