+2007-05-15 Wolfgang Sourdeau <WSourdeau@Inverse.CA>
+
+ * NGMime.m: encode string body contents using the charset
+ of the content-type (when available) (OGo bug #1873) (v4.7.245)
+
2007-05-28 Helge Hess <helge.hess@opengroupware.org>
* NGImap4: changed behaviour wrt bug 1875 (v4.7.244)
+2007-05-15 Wolfgang Sourdeau <WSourdeau@Inverse.CA>
+
+ * NGMimeBodyGenerator.m: encode string body contents using the charset
+ of the content-type (when available) (OGo bug #1873)
+
2006-02-22 Helge Hess <helge.hess@opengroupware.org>
* NGMimeRFC822DateHeaderFieldParser.m: added hardcoded detection for
/*
- Copyright (C) 2000-2005 SKYRIX Software AG
+ Copyright (C) 2000-2007 SKYRIX Software AG
+ Copyright (C) 2007 Helge Hess
This file is part of SOPE.
NSStringFromClass([self superclass]), [super version]);
}
+- (NSStringEncoding)_encodingFromContentType:(NGMimeType *)_type {
+ NSStringEncoding encoding;
+ NSString *charset;
+
+ encoding = [NSString defaultCStringEncoding];
+ if (_type != nil) {
+ charset = [_type valueOfParameter: @"charset"];
+ if ([charset length] > 0) {
+ if ([charset isEqualToString: @"utf-8"])
+ encoding = NSUTF8StringEncoding;
+ else if ([charset isEqualToString: @"iso-8859-1"])
+ encoding = NSISOLatin1StringEncoding;
+ /* more should be handled here */
+ }
+ }
+
+ return encoding;
+}
+
- (NSData *)generateBodyOfPart:(id<NGMimePart>)_part
additionalHeaders:(NGMutableHashMap *)_addHeaders
delegate:(id)_delegate
NSData *data;
id body;
- encoding = [NSString defaultCStringEncoding];
+ encoding = [self _encodingFromContentType: [_part contentType]];
body = [_part body];
data = nil;
- if ([body isKindOfClass:[NSString class]]) {
- // TODO: deal with charset in content-type!
+ if ([body isKindOfClass:[NSString class]])
data = [body dataUsingEncoding:encoding];
- }
else if ([body respondsToSelector:@selector(bytes)])
data = body;
else if ([body respondsToSelector:@selector(dataUsingEncoding:)])