JSON-Data als attachment in E-Mail: Problem mit encodings.

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • JSON-Data als attachment in E-Mail: Problem mit encodings.

    Hallo Zusammen,

    Ich schreibe mein Object in Dictionary:

    [myDic setObject:tName forKey:@"tName"];
    [myDic setObject:tDetail forKey:@"tDetail"];
    [myDic setObject:tAdress forKey:@"tAdress"];

    und dann sende ein E-mail mit JSON-Datei:

    NSData *result = [NSJSONSerialization dataWithJSONObject:myDict options:NSJSONWritingPrettyPrinted error:&error];
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    [picker addAttachmentData:result mimeType:@"application/json" fileName:@"MyApp-JSON.data"];
    ....

    In App bearbeite ich ein Attachment aus der E-Mail. Und bei deserialisieren JSON-Datei:

    NSData *jData = [NSData dataWithContentsOfURL:url];
    NSError* error;
    NSDictionary *tDictionary = [NSJSONSerialization JSONObjectWithData:jData options:kNilOptions error:&error];

    ...habe ich ein Problem mit encoding (Buchstaben: ü, ö, ß).

    NSString *tmpDetail = [tDictionary objectForKey:@"tDetail"];
    ---
    NSLOG: application:openURL:sourceApplication:annotation: detail: Fu√üballspielplatz, adress: Im B√ºhl 15, 51375, Leverkusen, DE <---- soll Fußballspielplatz, ..., Im Bühl...

    Was mache ich falsch? Wie soll man richtig mit encoding und JSON arbeiten?

    Danke.

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von juris ()

  • Manfred Kreß schrieb:

    speicherst du die JSON Daten zwischenzeitlich in einer Datenbank? Dann hier auch auf UTF8 achten.


    Nein.
    Erstelle Dictionary, dann sofort -> JSON und in E-Mail.

    Ich versende E-Mail mit JSON-Attachment auf der Adresse an web.de. Dann öffne auf iPhone standard Mail-App und rufe JSON-Attachment aus E-mail auf (wird mein App gestarted).