1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2006-2008, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9 package com.ibm.icu.charset; 10 11 interface UConverterConstants { 12 13 static final short UNSIGNED_BYTE_MASK = 0xff; 14 static final int UNSIGNED_SHORT_MASK = 0xffff; 15 static final long UNSIGNED_INT_MASK = 0xffffffffL; 16 17 static final int U_IS_BIG_ENDIAN = 0; 18 19 /** 20 * Useful constant for the maximum size of the whole locale ID 21 * (including the terminating NULL). 22 */ 23 static final int ULOC_FULLNAME_CAPACITY = 56; 24 25 /** 26 * This value is intended for sentinel values for APIs that 27 * (take or) return single code points (UChar32). 28 * It is outside of the Unicode code point range 0..0x10ffff. 29 * 30 * For example, a "done" or "error" value in a new API 31 * could be indicated with U_SENTINEL. 32 * 33 * ICU APIs designed before ICU 2.4 usually define service-specific "done" 34 * values, mostly 0xffff. 35 * Those may need to be distinguished from 36 * actual U+ffff text contents by calling functions like 37 * CharacterIterator::hasNext() or UnicodeString::length(). 38 */ 39 static final int U_SENTINEL = -1; 40 41 //end utf.h 42 43 //begin ucnv.h 44 /** 45 * Character that separates converter names from options and options from each other. 46 * @see CharsetICU#forNameICU(String) 47 */ 48 static final byte OPTION_SEP_CHAR = ','; 49 50 /** Maximum length of a converter name including the terminating NULL */ 51 static final int MAX_CONVERTER_NAME_LENGTH = 60; 52 /** Maximum length of a converter name including path and terminating NULL */ 53 static final int MAX_FULL_FILE_NAME_LENGTH = (600+MAX_CONVERTER_NAME_LENGTH); 54 55 /** Shift in for EBDCDIC_STATEFUL and iso2022 states */ 56 static final int SI = 0x0F; 57 /** Shift out for EBDCDIC_STATEFUL and iso2022 states */ 58 static final int SO = 0x0E; 59 60 //end ucnv.h 61 62 // begin bld.h 63 /* size of the overflow buffers in UConverter, enough for escaping callbacks */ 64 //#define ERROR_BUFFER_LENGTH 32 65 static final int ERROR_BUFFER_LENGTH = 32; 66 67 /* at most 4 bytes per substitution character (part of .cnv file format! see UConverterStaticData) */ 68 static final int MAX_SUBCHAR_LEN = 4; 69 70 /* at most 8 bytes per character in toUBytes[] (UTF-8 uses up to 6) */ 71 static final int MAX_CHAR_LEN = 8; 72 73 /* converter options bits */ 74 static final int OPTION_VERSION = 0xf; 75 static final int OPTION_SWAP_LFNL = 0x10; 76 static final int OPTION_MAC = 0x20; //agljport:comment added for Mac ISCII encodings 77 78 static final String OPTION_SWAP_LFNL_STRING = ",swaplfnl"; 79 80 /** values for the unicodeMask */ 81 static final int HAS_SUPPLEMENTARY = 1; 82 static final int HAS_SURROGATES = 2; 83 // end bld.h 84 85 // begin cnv.h 86 /* this is used in fromUnicode DBCS tables as an "unassigned" marker */ 87 static final int missingCharMarker = 0xFFFF; 88 /** 89 * 90 * @author ram 91 */ 92 static interface UConverterResetChoice { 93 static final int RESET_BOTH = 0; 94 static final int RESET_TO_UNICODE = RESET_BOTH + 1; 95 static final int RESET_FROM_UNICODE = RESET_TO_UNICODE + 1; 96 } 97 98 // begin utf16.h 99 /** 100 * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff). 101 */ 102 static final int U16_MAX_LENGTH = 2; 103 // end utf16.h 104 105 // begin err.h 106 /** 107 * FROM_U, TO_U context options for sub callback 108 */ 109 static byte[] SUB_STOP_ON_ILLEGAL = {'i'}; 110 111 /** 112 * FROM_U, TO_U context options for skip callback 113 */ 114 static byte[] SKIP_STOP_ON_ILLEGAL = {'i'}; 115 116 /** 117 * The process condition code to be used with the callbacks. 118 * Codes which are greater than IRREGULAR should be 119 * passed on to any chained callbacks. 120 */ 121 static interface UConverterCallbackReason { 122 static final int UNASSIGNED = 0; /**< The code point is unassigned. 123 The error code U_INVALID_CHAR_FOUND will be set. */ 124 static final int ILLEGAL = 1; /**< The code point is illegal. For example, 125 \\x81\\x2E is illegal in SJIS because \\x2E 126 is not a valid trail byte for the \\x81 127 lead byte. 128 Also, starting with Unicode 3.0.1, non-shortest byte sequences 129 in UTF-8 (like \\xC1\\xA1 instead of \\x61 for U+0061) 130 are also illegal, not just irregular. 131 The error code U_ILLEGAL_CHAR_FOUND will be set. */ 132 static final int IRREGULAR = 2; /**< The codepoint is not a regular sequence in 133 the encoding. For example, \\xED\\xA0\\x80..\\xED\\xBF\\xBF 134 are irregular UTF-8 byte sequences for single surrogate 135 code points. 136 The error code U_INVALID_CHAR_FOUND will be set. */ 137 static final int RESET = 3; /**< The callback is called with this reason when a 138 'reset' has occured. Callback should reset all 139 state. */ 140 static final int CLOSE = 4; /**< Called when the converter is closed. The 141 callback should release any allocated memory.*/ 142 static final int CLONE = 5; /**< Called when safeClone() is called on the 143 converter. the pointer available as the 144 'context' is an alias to the original converters' 145 context pointer. If the context must be owned 146 by the new converter, the callback must clone 147 the data and call setFromUCallback 148 (or setToUCallback) with the correct pointer. 149 */ 150 } 151 //end err.h 152 153 154 static final String DATA_TYPE = "cnv"; 155 static final int CNV_DATA_BUFFER_SIZE = 25000; 156 static final int SIZE_OF_UCONVERTER_SHARED_DATA = 100; 157 158 static final int MAXIMUM_UCS2 = 0x0000FFFF; 159 static final int MAXIMUM_UTF = 0x0010FFFF; 160 //static final int MAXIMUM_UCS4 = 0x7FFFFFFF; 161 static final int HALF_SHIFT = 10; 162 static final int HALF_BASE = 0x0010000; 163 static final int HALF_MASK = 0x3FF; 164 static final int SURROGATE_HIGH_START = 0xD800; 165 static final int SURROGATE_HIGH_END = 0xDBFF; 166 static final int SURROGATE_LOW_START = 0xDC00; 167 static final int SURROGATE_LOW_END = 0xDFFF; 168 169 /* -SURROGATE_LOW_START + HALF_BASE */ 170 static final int SURROGATE_LOW_BASE = 9216; 171 } 172