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