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