charconvfw/Charconv/ongoing/test/source/otherutf/UTF8.H
branchRCL_3
changeset 55 336bee5c2d35
equal deleted inserted replaced
54:748ec5531811 55:336bee5c2d35
       
     1 /* ================================================================ */
       
     2 /*
       
     3 File:	ConvertUTF.h
       
     4 Author: Mark E. Davis
       
     5 Copyright (C) 1994 Taligent, Inc. All rights reserved.
       
     6 
       
     7 This code is copyrighted. Under the copyright laws, this code may not
       
     8 be copied, in whole or part, without prior written consent of Taligent. 
       
     9 
       
    10 Taligent grants the right to use or reprint this code as long as this
       
    11 ENTIRE copyright notice is reproduced in the code or reproduction.
       
    12 The code is provided AS-IS, AND TALIGENT DISCLAIMS ALL WARRANTIES,
       
    13 EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED
       
    14 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN
       
    15 NO EVENT WILL TALIGENT BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING,
       
    16 WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
       
    17 INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
       
    18 LOSS) ARISING OUT OF THE USE OR INABILITY TO USE THIS CODE, EVEN
       
    19 IF TALIGENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
       
    20 BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
       
    21 LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
       
    22 LIMITATION MAY NOT APPLY TO YOU.
       
    23 
       
    24 RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
       
    25 government is subject to restrictions as set forth in subparagraph
       
    26 (c)(l)(ii) of the Rights in Technical Data and Computer Software
       
    27 clause at DFARS 252.227-7013 and FAR 52.227-19.
       
    28 
       
    29 This code may be protected by one or more U.S. and International
       
    30 Patents.
       
    31 
       
    32 TRADEMARKS: Taligent and the Taligent Design Mark are registered
       
    33 trademarks of Taligent, Inc.
       
    34 */
       
    35 /* ================================================================ */
       
    36 
       
    37 // #include <stdio.h> // commented out by DPB
       
    38 // #include <stdlib.h> // commented out by DPB
       
    39 // #include <types.h>
       
    40 // #include <string.h> // commented out by DPB
       
    41 #if !defined(__E32STD_H__) // added by DPB
       
    42 #include <e32std.h> // added by DPB
       
    43 #endif // added by DPB
       
    44 
       
    45 /* ================================================================ */
       
    46 /*	The following 4 definitions are compiler-specific.
       
    47 	I would use wchar_t for UCS2/UTF16, except that the C standard
       
    48 	does not guarantee that it has at least 16 bits, so wchar_t is
       
    49 	no less portable than unsigned short!
       
    50 */
       
    51 
       
    52 typedef unsigned long	UCS4;
       
    53 typedef unsigned short	UCS2;
       
    54 typedef unsigned short	UTF16;
       
    55 typedef unsigned char	UTF8;
       
    56 
       
    57 // typedef enum {false, true} Boolean; // commented out by DPB
       
    58 
       
    59 
       
    60 const UCS4 kReplacementCharacter =	0x0000FFFDUL;
       
    61 const UCS4 kMaximumUCS2 =			0x0000FFFFUL;
       
    62 const UCS4 kMaximumUTF16 =			0x0010FFFFUL;
       
    63 const UCS4 kMaximumUCS4 =			0x7FFFFFFFUL;
       
    64 
       
    65 /* ================================================================ */
       
    66 /*	Each of these routines converts the text between *sourceStart and 
       
    67 sourceEnd, putting the result into the buffer between *targetStart and
       
    68 targetEnd. Note: the end pointers are *after* the last item: e.g. 
       
    69 *(sourceEnd - 1) is the last item.
       
    70 
       
    71 	The return result indicates whether the conversion was successful,
       
    72 and if not, whether the problem was in the source or target buffers.
       
    73 
       
    74 	After the conversion, *sourceStart and *targetStart are both
       
    75 updated to point to the end of last text successfully converted in
       
    76 the respective buffers.
       
    77 */
       
    78 
       
    79 typedef enum {
       
    80 	ok, 				/* conversion successful */
       
    81 	sourceExhausted,	/* partial character in source, but hit end */
       
    82 	targetExhausted		/* insuff. room in target for conversion */
       
    83 } ConversionResult;
       
    84 
       
    85 IMPORT_C // added by DPB
       
    86 ConversionResult	ConvertUCS4toUTF16 (
       
    87 		UCS4** sourceStart, const UCS4* sourceEnd, 
       
    88 		UTF16** targetStart, const UTF16* targetEnd);
       
    89 
       
    90 IMPORT_C // added by DPB
       
    91 ConversionResult	ConvertUTF16toUCS4 (
       
    92 		UTF16** sourceStart, UTF16* sourceEnd, 
       
    93 		UCS4** targetStart, const UCS4* targetEnd);
       
    94 
       
    95 IMPORT_C // added by DPB
       
    96 ConversionResult	ConvertUTF16toUTF8 (
       
    97 		UTF16** sourceStart, const UTF16* sourceEnd, 
       
    98 		UTF8** targetStart, const UTF8* targetEnd);
       
    99 		
       
   100 IMPORT_C // added by DPB
       
   101 ConversionResult	ConvertUTF8toUTF16 (
       
   102 		UTF8** sourceStart, UTF8* sourceEnd, 
       
   103 		UTF16** targetStart, const UTF16* targetEnd);
       
   104 
       
   105 IMPORT_C // added by DPB
       
   106 ConversionResult	ConvertUCS4toUTF8 (
       
   107 		UCS4** sourceStart, const UCS4* sourceEnd, 
       
   108 		UTF8** targetStart, const UTF8* targetEnd);
       
   109 		
       
   110 IMPORT_C // added by DPB
       
   111 ConversionResult	ConvertUTF8toUCS4 (
       
   112 		UTF8** sourceStart, UTF8* sourceEnd, 
       
   113 		UCS4** targetStart, const UCS4* targetEnd);
       
   114 
       
   115 /* ================================================================ */