]> err.no Git - sope/blob - sope-core/NGExtensions/NGExtensions/NGQuotedPrintableCoding.h
quickfix for Leopard compile
[sope] / sope-core / NGExtensions / NGExtensions / NGQuotedPrintableCoding.h
1 /*
2   Copyright (C) 2000-2006 SKYRIX Software AG
3   Copyright (C) 2006      Helge Hess
4
5   This file is part of SOPE.
6
7   SOPE is free software; you can redistribute it and/or modify it under
8   the terms of the GNU Lesser General Public License as published by the
9   Free Software Foundation; either version 2, or (at your option) any
10   later version.
11
12   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
13   WARRANTY; without even the implied warranty of MERCHANTABILITY or
14   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15   License for more details.
16
17   You should have received a copy of the GNU Lesser General Public
18   License along with SOPE; see the file COPYING.  If not, write to the
19   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20   02111-1307, USA.
21 */
22
23 #ifndef __NGExtensions_NGQuotedPrintableCoding_H__
24 #define __NGExtensions_NGQuotedPrintableCoding_H__
25
26 #import <Foundation/NSString.h>
27 #import <Foundation/NSData.h>
28 #include <NGExtensions/NGExtensionsDecls.h>
29
30 /*
31   Quoted Printable encoder/decoder
32
33   As specified in RFC 822 / 2045 / 2047. Note that 2045 and 2047 specify
34   different variants (Q vs content-transfer-encoding)
35
36   TODO: explain what it does. It doesn't seem to decode a full line like
37           "=?iso-8859-1?q?Yannick=20DAmboise?="
38         but only turns "=20D" style encodings to their charcode.
39         
40   Note: apparently sope-mime contains a category on NSData which provides a
41         method to decode the full value:
42           -decodeQuotedPrintableValueOfMIMEHeaderField:
43         (NGMimeMessageParser)
44 */
45
46 @interface NSData(QuotedPrintableCoding)
47
48 /*
49   Decode a quoted printable encoded data. Returns nil if decoding failed. The
50   first method does the RFC 2047 variant, the second RFC 2045 (w/o _ replacing)
51 */
52 - (NSData *)dataByDecodingQuotedPrintable;
53 - (NSData *)dataByDecodingQuotedPrintableTransferEncoding;
54
55 /*
56   Decode data in quoted printable encoding. Returns nil if encoding failed.
57 */
58 - (NSData *)dataByEncodingQuotedPrintable;
59
60 @end
61
62
63 /* Note: you should avoid NSString methods for QP, its defined on byte level */
64 @interface NSString(QuotedPrintableCoding)
65
66 - (NSString *)stringByDecodingQuotedPrintable;
67 - (NSString *)stringByEncodingQuotedPrintable;
68
69 @end
70
71
72 NGExtensions_EXPORT int
73 NGEncodeQuotedPrintable(const char *_src, unsigned _srcLen,
74                         char *_dest, unsigned _destLen);
75 NGExtensions_EXPORT int
76 NGDecodeQuotedPrintable(const char *_src, unsigned _srcLen,
77                         char *_dest, unsigned _destLen);
78 NGExtensions_EXPORT int
79 NGDecodeQuotedPrintableX(const char *_src, unsigned _srcLen,
80                          char *_dest, unsigned _destLen,
81                          BOOL _replaceUnderline);
82
83 #endif /* __NGExtensions_NGQuotedPrintableCoding_H__ */