vrshoot

diff libs/assimp/ConvertUTF/ConvertUTF.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/ConvertUTF/ConvertUTF.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,151 @@
     1.4 +/*
     1.5 + * Copyright 2001-2004 Unicode, Inc.
     1.6 + * 
     1.7 + * Disclaimer
     1.8 + * 
     1.9 + * This source code is provided as is by Unicode, Inc. No claims are
    1.10 + * made as to fitness for any particular purpose. No warranties of any
    1.11 + * kind are expressed or implied. The recipient agrees to determine
    1.12 + * applicability of information provided. If this file has been
    1.13 + * purchased on magnetic or optical media from Unicode, Inc., the
    1.14 + * sole remedy for any claim will be exchange of defective media
    1.15 + * within 90 days of receipt.
    1.16 + * 
    1.17 + * Limitations on Rights to Redistribute This Code
    1.18 + * 
    1.19 + * Unicode, Inc. hereby grants the right to freely use the information
    1.20 + * supplied in this file in the creation of products supporting the
    1.21 + * Unicode Standard, and to make copies of this file in any form
    1.22 + * for internal or external distribution as long as this notice
    1.23 + * remains attached.
    1.24 + */
    1.25 +#ifndef CONVERTUTF_H
    1.26 +#define CONVERTUTF_H
    1.27 +/* ---------------------------------------------------------------------
    1.28 +
    1.29 +    Conversions between UTF32, UTF-16, and UTF-8.  Header file.
    1.30 +
    1.31 +    Several funtions are included here, forming a complete set of
    1.32 +    conversions between the three formats.  UTF-7 is not included
    1.33 +    here, but is handled in a separate source file.
    1.34 +
    1.35 +    Each of these routines takes pointers to input buffers and output
    1.36 +    buffers.  The input buffers are const.
    1.37 +
    1.38 +    Each routine converts the text between *sourceStart and sourceEnd,
    1.39 +    putting the result into the buffer between *targetStart and
    1.40 +    targetEnd. Note: the end pointers are *after* the last item: e.g. 
    1.41 +    *(sourceEnd - 1) is the last item.
    1.42 +
    1.43 +    The return result indicates whether the conversion was successful,
    1.44 +    and if not, whether the problem was in the source or target buffers.
    1.45 +    (Only the first encountered problem is indicated.)
    1.46 +
    1.47 +    After the conversion, *sourceStart and *targetStart are both
    1.48 +    updated to point to the end of last text successfully converted in
    1.49 +    the respective buffers.
    1.50 +
    1.51 +    Input parameters:
    1.52 +	sourceStart - pointer to a pointer to the source buffer.
    1.53 +		The contents of this are modified on return so that
    1.54 +		it points at the next thing to be converted.
    1.55 +	targetStart - similarly, pointer to pointer to the target buffer.
    1.56 +	sourceEnd, targetEnd - respectively pointers to the ends of the
    1.57 +		two buffers, for overflow checking only.
    1.58 +
    1.59 +    These conversion functions take a ConversionFlags argument. When this
    1.60 +    flag is set to strict, both irregular sequences and isolated surrogates
    1.61 +    will cause an error.  When the flag is set to lenient, both irregular
    1.62 +    sequences and isolated surrogates are converted.
    1.63 +
    1.64 +    Whether the flag is strict or lenient, all illegal sequences will cause
    1.65 +    an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>,
    1.66 +    or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code
    1.67 +    must check for illegal sequences.
    1.68 +
    1.69 +    When the flag is set to lenient, characters over 0x10FFFF are converted
    1.70 +    to the replacement character; otherwise (when the flag is set to strict)
    1.71 +    they constitute an error.
    1.72 +
    1.73 +    Output parameters:
    1.74 +	The value "sourceIllegal" is returned from some routines if the input
    1.75 +	sequence is malformed.  When "sourceIllegal" is returned, the source
    1.76 +	value will point to the illegal value that caused the problem. E.g.,
    1.77 +	in UTF-8 when a sequence is malformed, it points to the start of the
    1.78 +	malformed sequence.  
    1.79 +
    1.80 +    Author: Mark E. Davis, 1994.
    1.81 +    Rev History: Rick McGowan, fixes & updates May 2001.
    1.82 +		 Fixes & updates, Sept 2001.
    1.83 +
    1.84 +------------------------------------------------------------------------ */
    1.85 +
    1.86 +/* ---------------------------------------------------------------------
    1.87 +    The following 4 definitions are compiler-specific.
    1.88 +    The C standard does not guarantee that wchar_t has at least
    1.89 +    16 bits, so wchar_t is no less portable than unsigned short!
    1.90 +    All should be unsigned values to avoid sign extension during
    1.91 +    bit mask & shift operations.
    1.92 +------------------------------------------------------------------------ */
    1.93 +
    1.94 +typedef unsigned long	UTF32;	/* at least 32 bits */
    1.95 +typedef unsigned short	UTF16;	/* at least 16 bits */
    1.96 +typedef unsigned char	UTF8;	/* typically 8 bits */
    1.97 +typedef unsigned char	Boolean; /* 0 or 1 */
    1.98 +
    1.99 +/* Some fundamental constants */
   1.100 +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
   1.101 +#define UNI_MAX_BMP (UTF32)0x0000FFFF
   1.102 +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
   1.103 +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
   1.104 +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
   1.105 +
   1.106 +typedef enum {
   1.107 +	conversionOK, 		/* conversion successful */
   1.108 +	sourceExhausted,	/* partial character in source, but hit end */
   1.109 +	targetExhausted,	/* insuff. room in target for conversion */
   1.110 +	sourceIllegal		/* source sequence is illegal/malformed */
   1.111 +} ConversionResult;
   1.112 +
   1.113 +typedef enum {
   1.114 +	strictConversion = 0,
   1.115 +	lenientConversion
   1.116 +} ConversionFlags;
   1.117 +
   1.118 +/* This is for C++ and does no harm in C */
   1.119 +#ifdef __cplusplus
   1.120 +extern "C" {
   1.121 +#endif
   1.122 +
   1.123 +ConversionResult ConvertUTF8toUTF16 (
   1.124 +		const UTF8** sourceStart, const UTF8* sourceEnd, 
   1.125 +		UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
   1.126 +
   1.127 +ConversionResult ConvertUTF16toUTF8 (
   1.128 +		const UTF16** sourceStart, const UTF16* sourceEnd, 
   1.129 +		UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
   1.130 +		
   1.131 +ConversionResult ConvertUTF8toUTF32 (
   1.132 +		const UTF8** sourceStart, const UTF8* sourceEnd, 
   1.133 +		UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
   1.134 +
   1.135 +ConversionResult ConvertUTF32toUTF8 (
   1.136 +		const UTF32** sourceStart, const UTF32* sourceEnd, 
   1.137 +		UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
   1.138 +		
   1.139 +ConversionResult ConvertUTF16toUTF32 (
   1.140 +		const UTF16** sourceStart, const UTF16* sourceEnd, 
   1.141 +		UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
   1.142 +
   1.143 +ConversionResult ConvertUTF32toUTF16 (
   1.144 +		const UTF32** sourceStart, const UTF32* sourceEnd, 
   1.145 +		UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
   1.146 +
   1.147 +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);
   1.148 +
   1.149 +#ifdef __cplusplus
   1.150 +}
   1.151 +#endif
   1.152 +
   1.153 +/* --------------------------------------------------------------------- */
   1.154 +#endif  // CONVERTUTF_H