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