intl/icu/source/common/unicode/ucnvsel.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2008-2011, International Business Machines
michael@0 5 * Corporation, Google and others. All Rights Reserved.
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 */
michael@0 9 /*
michael@0 10 * Author : eldawy@google.com (Mohamed Eldawy)
michael@0 11 * ucnvsel.h
michael@0 12 *
michael@0 13 * Purpose: To generate a list of encodings capable of handling
michael@0 14 * a given Unicode text
michael@0 15 *
michael@0 16 * Started 09-April-2008
michael@0 17 */
michael@0 18
michael@0 19 #ifndef __ICU_UCNV_SEL_H__
michael@0 20 #define __ICU_UCNV_SEL_H__
michael@0 21
michael@0 22 #include "unicode/utypes.h"
michael@0 23
michael@0 24 #if !UCONFIG_NO_CONVERSION
michael@0 25
michael@0 26 #include "unicode/uset.h"
michael@0 27 #include "unicode/utf16.h"
michael@0 28 #include "unicode/uenum.h"
michael@0 29 #include "unicode/ucnv.h"
michael@0 30 #include "unicode/localpointer.h"
michael@0 31
michael@0 32 /**
michael@0 33 * \file
michael@0 34 *
michael@0 35 * A converter selector is built with a set of encoding/charset names
michael@0 36 * and given an input string returns the set of names of the
michael@0 37 * corresponding converters which can convert the string.
michael@0 38 *
michael@0 39 * A converter selector can be serialized into a buffer and reopened
michael@0 40 * from the serialized form.
michael@0 41 */
michael@0 42
michael@0 43 /**
michael@0 44 * @{
michael@0 45 * The selector data structure
michael@0 46 */
michael@0 47 struct UConverterSelector;
michael@0 48 typedef struct UConverterSelector UConverterSelector;
michael@0 49 /** @} */
michael@0 50
michael@0 51 /**
michael@0 52 * Open a selector.
michael@0 53 * If converterListSize is 0, build for all available converters.
michael@0 54 * If excludedCodePoints is NULL, don't exclude any code points.
michael@0 55 *
michael@0 56 * @param converterList a pointer to encoding names needed to be involved.
michael@0 57 * Can be NULL if converterListSize==0.
michael@0 58 * The list and the names will be cloned, and the caller
michael@0 59 * retains ownership of the original.
michael@0 60 * @param converterListSize number of encodings in above list.
michael@0 61 * If 0, builds a selector for all available converters.
michael@0 62 * @param excludedCodePoints a set of code points to be excluded from consideration.
michael@0 63 * That is, excluded code points in a string do not change
michael@0 64 * the selection result. (They might be handled by a callback.)
michael@0 65 * Use NULL to exclude nothing.
michael@0 66 * @param whichSet what converter set to use? Use this to determine whether
michael@0 67 * to consider only roundtrip mappings or also fallbacks.
michael@0 68 * @param status an in/out ICU UErrorCode
michael@0 69 * @return the new selector
michael@0 70 *
michael@0 71 * @stable ICU 4.2
michael@0 72 */
michael@0 73 U_STABLE UConverterSelector* U_EXPORT2
michael@0 74 ucnvsel_open(const char* const* converterList, int32_t converterListSize,
michael@0 75 const USet* excludedCodePoints,
michael@0 76 const UConverterUnicodeSet whichSet, UErrorCode* status);
michael@0 77
michael@0 78 /**
michael@0 79 * Closes a selector.
michael@0 80 * If any Enumerations were returned by ucnv_select*, they become invalid.
michael@0 81 * They can be closed before or after calling ucnv_closeSelector,
michael@0 82 * but should never be used after the selector is closed.
michael@0 83 *
michael@0 84 * @see ucnv_selectForString
michael@0 85 * @see ucnv_selectForUTF8
michael@0 86 *
michael@0 87 * @param sel selector to close
michael@0 88 *
michael@0 89 * @stable ICU 4.2
michael@0 90 */
michael@0 91 U_STABLE void U_EXPORT2
michael@0 92 ucnvsel_close(UConverterSelector *sel);
michael@0 93
michael@0 94 #if U_SHOW_CPLUSPLUS_API
michael@0 95
michael@0 96 U_NAMESPACE_BEGIN
michael@0 97
michael@0 98 /**
michael@0 99 * \class LocalUConverterSelectorPointer
michael@0 100 * "Smart pointer" class, closes a UConverterSelector via ucnvsel_close().
michael@0 101 * For most methods see the LocalPointerBase base class.
michael@0 102 *
michael@0 103 * @see LocalPointerBase
michael@0 104 * @see LocalPointer
michael@0 105 * @stable ICU 4.4
michael@0 106 */
michael@0 107 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterSelectorPointer, UConverterSelector, ucnvsel_close);
michael@0 108
michael@0 109 U_NAMESPACE_END
michael@0 110
michael@0 111 #endif
michael@0 112
michael@0 113 /**
michael@0 114 * Open a selector from its serialized form.
michael@0 115 * The buffer must remain valid and unchanged for the lifetime of the selector.
michael@0 116 * This is much faster than creating a selector from scratch.
michael@0 117 * Using a serialized form from a different machine (endianness/charset) is supported.
michael@0 118 *
michael@0 119 * @param buffer pointer to the serialized form of a converter selector;
michael@0 120 * must be 32-bit-aligned
michael@0 121 * @param length the capacity of this buffer (can be equal to or larger than
michael@0 122 * the actual data length)
michael@0 123 * @param status an in/out ICU UErrorCode
michael@0 124 * @return the new selector
michael@0 125 *
michael@0 126 * @stable ICU 4.2
michael@0 127 */
michael@0 128 U_STABLE UConverterSelector* U_EXPORT2
michael@0 129 ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* status);
michael@0 130
michael@0 131 /**
michael@0 132 * Serialize a selector into a linear buffer.
michael@0 133 * The serialized form is portable to different machines.
michael@0 134 *
michael@0 135 * @param sel selector to consider
michael@0 136 * @param buffer pointer to 32-bit-aligned memory to be filled with the
michael@0 137 * serialized form of this converter selector
michael@0 138 * @param bufferCapacity the capacity of this buffer
michael@0 139 * @param status an in/out ICU UErrorCode
michael@0 140 * @return the required buffer capacity to hold serialize data (even if the call fails
michael@0 141 * with a U_BUFFER_OVERFLOW_ERROR, it will return the required capacity)
michael@0 142 *
michael@0 143 * @stable ICU 4.2
michael@0 144 */
michael@0 145 U_STABLE int32_t U_EXPORT2
michael@0 146 ucnvsel_serialize(const UConverterSelector* sel,
michael@0 147 void* buffer, int32_t bufferCapacity, UErrorCode* status);
michael@0 148
michael@0 149 /**
michael@0 150 * Select converters that can map all characters in a UTF-16 string,
michael@0 151 * ignoring the excluded code points.
michael@0 152 *
michael@0 153 * @param sel a selector
michael@0 154 * @param s UTF-16 string
michael@0 155 * @param length length of the string, or -1 if NUL-terminated
michael@0 156 * @param status an in/out ICU UErrorCode
michael@0 157 * @return an enumeration containing encoding names.
michael@0 158 * The returned encoding names and their order will be the same as
michael@0 159 * supplied when building the selector.
michael@0 160 *
michael@0 161 * @stable ICU 4.2
michael@0 162 */
michael@0 163 U_STABLE UEnumeration * U_EXPORT2
michael@0 164 ucnvsel_selectForString(const UConverterSelector* sel,
michael@0 165 const UChar *s, int32_t length, UErrorCode *status);
michael@0 166
michael@0 167 /**
michael@0 168 * Select converters that can map all characters in a UTF-8 string,
michael@0 169 * ignoring the excluded code points.
michael@0 170 *
michael@0 171 * @param sel a selector
michael@0 172 * @param s UTF-8 string
michael@0 173 * @param length length of the string, or -1 if NUL-terminated
michael@0 174 * @param status an in/out ICU UErrorCode
michael@0 175 * @return an enumeration containing encoding names.
michael@0 176 * The returned encoding names and their order will be the same as
michael@0 177 * supplied when building the selector.
michael@0 178 *
michael@0 179 * @stable ICU 4.2
michael@0 180 */
michael@0 181 U_STABLE UEnumeration * U_EXPORT2
michael@0 182 ucnvsel_selectForUTF8(const UConverterSelector* sel,
michael@0 183 const char *s, int32_t length, UErrorCode *status);
michael@0 184
michael@0 185 #endif /* !UCONFIG_NO_CONVERSION */
michael@0 186
michael@0 187 #endif /* __ICU_UCNV_SEL_H__ */

mercurial