intl/icu/source/common/ucnv_imp.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/ucnv_imp.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 1999-2011, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*
    1.10 +*
    1.11 +*  ucnv_imp.h:
    1.12 +*  Contains all internal and external data structure definitions
    1.13 +* Created & Maitained by Bertrand A. Damiba
    1.14 +*
    1.15 +*
    1.16 +*
    1.17 +* ATTENTION:
    1.18 +* ---------
    1.19 +* Although the data structures in this file are open and stack allocatable
    1.20 +* we reserve the right to hide them in further releases.
    1.21 +*/
    1.22 +
    1.23 +#ifndef UCNV_IMP_H
    1.24 +#define UCNV_IMP_H
    1.25 +
    1.26 +#include "unicode/utypes.h"
    1.27 +
    1.28 +#if !UCONFIG_NO_CONVERSION
    1.29 +
    1.30 +#include "unicode/uloc.h"
    1.31 +#include "ucnv_bld.h"
    1.32 +
    1.33 +/*
    1.34 + * Fast check for whether a charset name is "UTF-8".
    1.35 + * This does not recognize all of the variations that ucnv_open()
    1.36 + * and other functions recognize, but it covers most cases.
    1.37 + * @param name const char * charset name
    1.38 + * @return
    1.39 + */
    1.40 +#define UCNV_FAST_IS_UTF8(name) \
    1.41 +    (((name[0]=='U' ? \
    1.42 +      (                name[1]=='T' && name[2]=='F') : \
    1.43 +      (name[0]=='u' && name[1]=='t' && name[2]=='f'))) \
    1.44 +  && (name[3]=='-' ? \
    1.45 +     (name[4]=='8' && name[5]==0) : \
    1.46 +     (name[3]=='8' && name[4]==0)))
    1.47 +
    1.48 +typedef struct {
    1.49 +    char cnvName[UCNV_MAX_CONVERTER_NAME_LENGTH];
    1.50 +    char locale[ULOC_FULLNAME_CAPACITY];
    1.51 +    uint32_t options;
    1.52 +} UConverterNamePieces;
    1.53 +
    1.54 +U_CFUNC UBool
    1.55 +ucnv_canCreateConverter(const char *converterName, UErrorCode *err);
    1.56 +
    1.57 +/* figures out if we need to go to file to read in the data tables.
    1.58 + * @param converterName The name of the converter
    1.59 + * @param err The error code
    1.60 + * @return the newly created converter
    1.61 + */
    1.62 +U_CAPI UConverter *
    1.63 +ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err);
    1.64 +
    1.65 +/*
    1.66 + * Open a purely algorithmic converter, specified by a type constant.
    1.67 + * @param myUConverter  NULL, or pre-allocated UConverter structure to avoid
    1.68 + *                      a memory allocation
    1.69 + * @param type          requested converter type
    1.70 + * @param locale        locale parameter, or ""
    1.71 + * @param options       converter options bit set (default 0)
    1.72 + * @param err           ICU error code, not tested for U_FAILURE on input
    1.73 + *                      because this is an internal function
    1.74 + * @internal
    1.75 + */
    1.76 +U_CFUNC UConverter *
    1.77 +ucnv_createAlgorithmicConverter(UConverter *myUConverter,
    1.78 +                                UConverterType type,
    1.79 +                                const char *locale, uint32_t options,
    1.80 +                                UErrorCode *err);
    1.81 +
    1.82 +/*
    1.83 + * Creates a converter from shared data.
    1.84 + * Adopts mySharedConverterData: No matter what happens, the caller must not
    1.85 + * unload mySharedConverterData, except via ucnv_close(return value)
    1.86 + * if this function is successful.
    1.87 + */
    1.88 +U_CFUNC UConverter *
    1.89 +ucnv_createConverterFromSharedData(UConverter *myUConverter,
    1.90 +                                   UConverterSharedData *mySharedConverterData,
    1.91 +                                   UConverterLoadArgs *pArgs,
    1.92 +                                   UErrorCode *err);
    1.93 +
    1.94 +U_CFUNC UConverter *
    1.95 +ucnv_createConverterFromPackage(const char *packageName, const char *converterName, UErrorCode *err);
    1.96 +
    1.97 +/**
    1.98 + * Load a converter but do not create a UConverter object.
    1.99 + * Simply return the UConverterSharedData.
   1.100 + * Performs alias lookup etc.
   1.101 + * The UConverterNamePieces need not be initialized
   1.102 + * before calling this function.
   1.103 + * The UConverterLoadArgs must be initialized
   1.104 + * before calling this function.
   1.105 + * If the args are passed in, then the pieces must be passed in too.
   1.106 + * In other words, the following combinations are allowed:
   1.107 + * - pieces==NULL && args==NULL
   1.108 + * - pieces!=NULL && args==NULL
   1.109 + * - pieces!=NULL && args!=NULL
   1.110 + * @internal
   1.111 + */
   1.112 +U_CFUNC UConverterSharedData *
   1.113 +ucnv_loadSharedData(const char *converterName,
   1.114 +                    UConverterNamePieces *pieces,
   1.115 +                    UConverterLoadArgs *pArgs,
   1.116 +                    UErrorCode * err);
   1.117 +
   1.118 +/**
   1.119 + * This may unload the shared data in a thread safe manner.
   1.120 + * This will only unload the data if no other converters are sharing it.
   1.121 + */
   1.122 +U_CFUNC void
   1.123 +ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData);
   1.124 +
   1.125 +/**
   1.126 + * This is a thread safe way to increment the reference count.
   1.127 + */
   1.128 +U_CFUNC void
   1.129 +ucnv_incrementRefCount(UConverterSharedData *sharedData);
   1.130 +
   1.131 +/**
   1.132 + * These are the default error handling callbacks for the charset conversion framework.
   1.133 + * For performance reasons, they are only called to handle an error (not normally called for a reset or close).
   1.134 + */
   1.135 +#define UCNV_TO_U_DEFAULT_CALLBACK ((UConverterToUCallback) UCNV_TO_U_CALLBACK_SUBSTITUTE)
   1.136 +#define UCNV_FROM_U_DEFAULT_CALLBACK ((UConverterFromUCallback) UCNV_FROM_U_CALLBACK_SUBSTITUTE)
   1.137 +
   1.138 +#endif
   1.139 +
   1.140 +#endif /* _UCNV_IMP */

mercurial