blob: 362fdd0978b778ad869cebb910ffcf092cb87ce6 [file] [log] [blame]
Lucas Eckelsdc4699f2012-08-06 15:22:01 -07001/* ================================================================ */
2/*
3File: ConvertUTF7.h
4Author: David B. Goldsmith
5Copyright (C) 1994 IBM Corporation All rights reserved.
6Revisions: Header update only July, 2001.
7
8This code is copyrighted. Under the copyright laws, this code may not
9be copied, in whole or part, without prior written consent of IBM Corporation.
10
11IBM Corporation grants the right to use this code as long as this ENTIRE
12copyright notice is reproduced in the code. The code is provided
13AS-IS, AND IBM CORPORATION DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR
14IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED WARRANTIES OF
15MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
16WILL IBM CORPORATION BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING,
17WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
18INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
19LOSS) ARISING OUT OF THE USE OR INABILITY TO USE THIS CODE, EVEN
20IF IBM CORPORATION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
21BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
22LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
23LIMITATION MAY NOT APPLY TO YOU.
24
25RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
26government is subject to restrictions as set forth in subparagraph
27(c)(l)(ii) of the Rights in Technical Data and Computer Software
28clause at DFARS 252.227-7013 and FAR 52.227-19.
29
30This code may be protected by one or more U.S. and International
31Patents.
32
33*/
34/* ================================================================ */
35
36/* ================================================================ */
37/* The following definitions are compiler-specific.
38 I would use wchar_t for UCS2/UTF16, except that the C standard
39 does not guarantee that it has at least 16 bits, so wchar_t is
40 no more portable than unsigned short!
41*/
42
43typedef unsigned short UCS2;
44
45/* ================================================================ */
46/* Each of these routines converts the text between *sourceStart and
47sourceEnd, putting the result into the buffer between *targetStart and
48targetEnd. Note: the end pointers are *after* the last item: e.g.
49*(sourceEnd - 1) is the last item.
50
51 The return result indicates whether the conversion was successful,
52and if not, whether the problem was in the source or target buffers.
53
54 After the conversion, *sourceStart and *targetStart are both
55updated to point to the end of last text successfully converted in
56the respective buffers.
57
58 In ConvertUCS2toUTF7, optional indicates whether UTF-7 optional
59characters should be directly encoded, and verbose controls whether the
60shift-out character, "-", is always emitted at the end of a shifted
61sequence.
62*/
63
64typedef enum {
65 ok, /* conversion successful */
66 sourceCorrupt, /* source contains invalid UTF-7 */
67 targetExhausted /* insuff. room in target for conversion */
68} ConversionResult;
69
70extern ConversionResult ConvertUCS2toUTF7 (
71 UCS2** sourceStart, UCS2* sourceEnd,
72 char** targetStart, char* targetEnd,
73 int optional, int verbose);
74
75extern ConversionResult ConvertUTF7toUCS2 (
76 char** sourceStart, char* sourceEnd,
77 UCS2** targetStart, UCS2* targetEnd);
78
79/* ================================================================ */