简体   繁体   中英

Encoding Subject Line for Email

The body of an email can be encoded according to encoding specified in a header. This cannot be done for the Subject, which must use a different format. How can this be done in Objective C. A working example of what I'm trying to do is shown at this website .

The output of the method should return what is being returned on this website on the second line: "Encoded Result:".

This is described in RFC 2047 . I'll wade through this, if necessary, but surely this has already been done.

    NSData *dataForSubject = [message.subject dataUsingEncoding:NSUTF8StringEncoding];
    NSString *base64Subject = [dataForSubject base64EncodedStringWithOptions:0];
    NSString *stringToPass = [NSString stringWithFormat:@"=?utf-8?b?%@?=",base64Subject];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM