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