]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/ucnv_cnv.h
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / common / ucnv_cnv.h
index e3de1014a04c3e35be4679db999087c68bbf9691..2eed2c60df60c3ace76533c9bcc3146ea83619a3 100644 (file)
@@ -1,12 +1,13 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 **********************************************************************
-*   Copyright (C) 1999-2004, International Business Machines
+*   Copyright (C) 1999-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *
-*   uconv_cnv.h:
-*   defines all the low level conversion functions
-*   T_UnicodeConverter_{to,from}Unicode_$ConversionType
+*   ucnv_cnv.h:
+*   Definitions for converter implementations.
 *
 * Modification History:
 *
@@ -50,17 +51,22 @@ typedef struct UConverterSharedData UConverterSharedData;
 typedef struct {
     int32_t size;               /* sizeof(UConverterLoadArgs) */
     int32_t nestedLoads;        /* count nested ucnv_load() calls */
-    int32_t reserved;           /* reserved - for good alignment of the pointers */
+    UBool onlyTestIsLoadable;   /* input: don't actually load */
+    UBool reserved0;            /* reserved - for good alignment of the pointers */
+    int16_t reserved;           /* reserved - for good alignment of the pointers */
     uint32_t options;
-    const char *pkg, *name;
+    const char *pkg, *name, *locale;
 } UConverterLoadArgs;
 
+#define UCNV_LOAD_ARGS_INITIALIZER \
+    { (int32_t)sizeof(UConverterLoadArgs), 0, FALSE, FALSE, 0, 0, NULL, NULL, NULL }
+
 typedef void (*UConverterLoad) (UConverterSharedData *sharedData,
                                 UConverterLoadArgs *pArgs,
                                 const uint8_t *raw, UErrorCode *pErrorCode);
 typedef void (*UConverterUnload) (UConverterSharedData *sharedData);
 
-typedef void (*UConverterOpen) (UConverter *cnv, const char *name, const char *locale,uint32_t options, UErrorCode *pErrorCode);
+typedef void (*UConverterOpen) (UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *pErrorCode);
 typedef void (*UConverterClose) (UConverter *cnv);
 
 typedef enum UConverterResetChoice {
@@ -104,6 +110,23 @@ typedef void (*UConverterToUnicode) (UConverterToUnicodeArgs *, UErrorCode *);
  */
 typedef void (*UConverterFromUnicode) (UConverterFromUnicodeArgs *, UErrorCode *);
 
+/*
+ * Converter implementation function for ucnv_convertEx(), for direct conversion
+ * between two charsets without pivoting through UTF-16.
+ * The rules are the same as for UConverterToUnicode and UConverterFromUnicode.
+ * In addition,
+ * - The toUnicode side must behave and keep state exactly like the
+ *   UConverterToUnicode implementation for the same source charset.
+ * - A U_USING_DEFAULT_WARNING can be set to request to temporarily fall back
+ *   to pivoting. When this function is called, the conversion framework makes
+ *   sure that this warning is not set on input.
+ * - Continuing a partial match and flushing the toUnicode replay buffer
+ *   are handled by pivoting, using the toUnicode and fromUnicode functions.
+ */
+typedef void (*UConverterConvert) (UConverterFromUnicodeArgs *pFromUArgs,
+                                   UConverterToUnicodeArgs *pToUArgs,
+                                   UErrorCode *pErrorCode);
+
 /*
  * Converter implementation function for ucnv_getNextUChar().
  * If the function pointer is NULL, then the toUnicode function will be used.
@@ -159,6 +182,19 @@ typedef UConverter * (*UConverterSafeClone) (const UConverter   *cnv,
                                              int32_t            *pBufferSize, 
                                              UErrorCode         *status);
 
+/**
+ * Filters for some ucnv_getUnicodeSet() implementation code.
+ */
+typedef enum UConverterSetFilter {
+    UCNV_SET_FILTER_NONE,
+    UCNV_SET_FILTER_DBCS_ONLY,
+    UCNV_SET_FILTER_2022_CN,
+    UCNV_SET_FILTER_SJIS,
+    UCNV_SET_FILTER_GR94DBCS,
+    UCNV_SET_FILTER_HZ,
+    UCNV_SET_FILTER_COUNT
+} UConverterSetFilter;
+
 /**
  * Fills the set of Unicode code points that can be converted by an ICU converter.
  * The API function ucnv_getUnicodeSet() clears the USet before calling
@@ -214,6 +250,9 @@ struct UConverterImpl {
     UConverterWriteSub writeSub;
     UConverterSafeClone safeClone;
     UConverterGetUnicodeSet getUnicodeSet;
+
+    UConverterConvert toUTF8;
+    UConverterConvert fromUTF8;
 };
 
 extern const UConverterSharedData
@@ -223,7 +262,7 @@ extern const UConverterSharedData
     _LMBCSData1,_LMBCSData2, _LMBCSData3, _LMBCSData4, _LMBCSData5, _LMBCSData6,
     _LMBCSData8,_LMBCSData11,_LMBCSData16,_LMBCSData17,_LMBCSData18,_LMBCSData19,
     _HZData,_ISCIIData, _SCSUData, _ASCIIData,
-    _UTF7Data, _Bocu1Data, _UTF16Data, _UTF32Data, _CESU8Data, _IMAPData;
+    _UTF7Data, _Bocu1Data, _UTF16Data, _UTF32Data, _CESU8Data, _IMAPData, _CompoundTextData;
 
 U_CDECL_END