12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 32e5b6d6dSopenharmony_ci/* 42e5b6d6dSopenharmony_ci******************************************************************************* 52e5b6d6dSopenharmony_ci* 62e5b6d6dSopenharmony_ci* Copyright (C) 2003-2015, International Business Machines 72e5b6d6dSopenharmony_ci* Corporation and others. All Rights Reserved. 82e5b6d6dSopenharmony_ci* 92e5b6d6dSopenharmony_ci******************************************************************************* 102e5b6d6dSopenharmony_ci* file name: ucol_swp.cpp 112e5b6d6dSopenharmony_ci* encoding: UTF-8 122e5b6d6dSopenharmony_ci* tab size: 8 (not used) 132e5b6d6dSopenharmony_ci* indentation:4 142e5b6d6dSopenharmony_ci* 152e5b6d6dSopenharmony_ci* created on: 2003sep10 162e5b6d6dSopenharmony_ci* created by: Markus W. Scherer 172e5b6d6dSopenharmony_ci* 182e5b6d6dSopenharmony_ci* Swap collation binaries. 192e5b6d6dSopenharmony_ci*/ 202e5b6d6dSopenharmony_ci 212e5b6d6dSopenharmony_ci#include "unicode/udata.h" /* UDataInfo */ 222e5b6d6dSopenharmony_ci#include "utrie.h" 232e5b6d6dSopenharmony_ci#include "utrie2.h" 242e5b6d6dSopenharmony_ci#include "udataswp.h" 252e5b6d6dSopenharmony_ci#include "cmemory.h" 262e5b6d6dSopenharmony_ci#include "ucol_data.h" 272e5b6d6dSopenharmony_ci#include "ucol_swp.h" 282e5b6d6dSopenharmony_ci 292e5b6d6dSopenharmony_ci/* swapping ----------------------------------------------------------------- */ 302e5b6d6dSopenharmony_ci 312e5b6d6dSopenharmony_ci#if !UCONFIG_NO_COLLATION 322e5b6d6dSopenharmony_ci 332e5b6d6dSopenharmony_ciU_CAPI UBool U_EXPORT2 342e5b6d6dSopenharmony_ciucol_looksLikeCollationBinary(const UDataSwapper *ds, 352e5b6d6dSopenharmony_ci const void *inData, int32_t length) { 362e5b6d6dSopenharmony_ci if(ds==NULL || inData==NULL || length<-1) { 372e5b6d6dSopenharmony_ci return false; 382e5b6d6dSopenharmony_ci } 392e5b6d6dSopenharmony_ci 402e5b6d6dSopenharmony_ci // First check for format version 4+ which has a standard data header. 412e5b6d6dSopenharmony_ci UErrorCode errorCode=U_ZERO_ERROR; 422e5b6d6dSopenharmony_ci (void)udata_swapDataHeader(ds, inData, -1, NULL, &errorCode); 432e5b6d6dSopenharmony_ci if(U_SUCCESS(errorCode)) { 442e5b6d6dSopenharmony_ci const UDataInfo &info=*(const UDataInfo *)((const char *)inData+4); 452e5b6d6dSopenharmony_ci if(info.dataFormat[0]==0x55 && // dataFormat="UCol" 462e5b6d6dSopenharmony_ci info.dataFormat[1]==0x43 && 472e5b6d6dSopenharmony_ci info.dataFormat[2]==0x6f && 482e5b6d6dSopenharmony_ci info.dataFormat[3]==0x6c) { 492e5b6d6dSopenharmony_ci return true; 502e5b6d6dSopenharmony_ci } 512e5b6d6dSopenharmony_ci } 522e5b6d6dSopenharmony_ci 532e5b6d6dSopenharmony_ci // Else check for format version 3. 542e5b6d6dSopenharmony_ci const UCATableHeader *inHeader=(const UCATableHeader *)inData; 552e5b6d6dSopenharmony_ci 562e5b6d6dSopenharmony_ci /* 572e5b6d6dSopenharmony_ci * The collation binary must contain at least the UCATableHeader, 582e5b6d6dSopenharmony_ci * starting with its size field. 592e5b6d6dSopenharmony_ci * sizeof(UCATableHeader)==42*4 in ICU 2.8 602e5b6d6dSopenharmony_ci * check the length against the header size before reading the size field 612e5b6d6dSopenharmony_ci */ 622e5b6d6dSopenharmony_ci UCATableHeader header; 632e5b6d6dSopenharmony_ci uprv_memset(&header, 0, sizeof(header)); 642e5b6d6dSopenharmony_ci if(length<0) { 652e5b6d6dSopenharmony_ci header.size=udata_readInt32(ds, inHeader->size); 662e5b6d6dSopenharmony_ci } else if((length<(42*4) || length<(header.size=udata_readInt32(ds, inHeader->size)))) { 672e5b6d6dSopenharmony_ci return false; 682e5b6d6dSopenharmony_ci } 692e5b6d6dSopenharmony_ci 702e5b6d6dSopenharmony_ci header.magic=ds->readUInt32(inHeader->magic); 712e5b6d6dSopenharmony_ci if(!( 722e5b6d6dSopenharmony_ci header.magic==UCOL_HEADER_MAGIC && 732e5b6d6dSopenharmony_ci inHeader->formatVersion[0]==3 /*&& 742e5b6d6dSopenharmony_ci inHeader->formatVersion[1]>=0*/ 752e5b6d6dSopenharmony_ci )) { 762e5b6d6dSopenharmony_ci return false; 772e5b6d6dSopenharmony_ci } 782e5b6d6dSopenharmony_ci 792e5b6d6dSopenharmony_ci if(inHeader->isBigEndian!=ds->inIsBigEndian || inHeader->charSetFamily!=ds->inCharset) { 802e5b6d6dSopenharmony_ci return false; 812e5b6d6dSopenharmony_ci } 822e5b6d6dSopenharmony_ci 832e5b6d6dSopenharmony_ci return true; 842e5b6d6dSopenharmony_ci} 852e5b6d6dSopenharmony_ci 862e5b6d6dSopenharmony_cinamespace { 872e5b6d6dSopenharmony_ci 882e5b6d6dSopenharmony_ci/* swap a header-less collation formatVersion=3 binary, inside a resource bundle or ucadata.icu */ 892e5b6d6dSopenharmony_ciint32_t 902e5b6d6dSopenharmony_ciswapFormatVersion3(const UDataSwapper *ds, 912e5b6d6dSopenharmony_ci const void *inData, int32_t length, void *outData, 922e5b6d6dSopenharmony_ci UErrorCode *pErrorCode) { 932e5b6d6dSopenharmony_ci const uint8_t *inBytes; 942e5b6d6dSopenharmony_ci uint8_t *outBytes; 952e5b6d6dSopenharmony_ci 962e5b6d6dSopenharmony_ci const UCATableHeader *inHeader; 972e5b6d6dSopenharmony_ci UCATableHeader *outHeader; 982e5b6d6dSopenharmony_ci UCATableHeader header; 992e5b6d6dSopenharmony_ci 1002e5b6d6dSopenharmony_ci uint32_t count; 1012e5b6d6dSopenharmony_ci 1022e5b6d6dSopenharmony_ci /* argument checking in case we were not called from ucol_swap() */ 1032e5b6d6dSopenharmony_ci if(U_FAILURE(*pErrorCode)) { 1042e5b6d6dSopenharmony_ci return 0; 1052e5b6d6dSopenharmony_ci } 1062e5b6d6dSopenharmony_ci if(ds==NULL || inData==NULL || length<-1 || (length>0 && outData==NULL)) { 1072e5b6d6dSopenharmony_ci *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; 1082e5b6d6dSopenharmony_ci return 0; 1092e5b6d6dSopenharmony_ci } 1102e5b6d6dSopenharmony_ci 1112e5b6d6dSopenharmony_ci inBytes=(const uint8_t *)inData; 1122e5b6d6dSopenharmony_ci outBytes=(uint8_t *)outData; 1132e5b6d6dSopenharmony_ci 1142e5b6d6dSopenharmony_ci inHeader=(const UCATableHeader *)inData; 1152e5b6d6dSopenharmony_ci outHeader=(UCATableHeader *)outData; 1162e5b6d6dSopenharmony_ci 1172e5b6d6dSopenharmony_ci /* 1182e5b6d6dSopenharmony_ci * The collation binary must contain at least the UCATableHeader, 1192e5b6d6dSopenharmony_ci * starting with its size field. 1202e5b6d6dSopenharmony_ci * sizeof(UCATableHeader)==42*4 in ICU 2.8 1212e5b6d6dSopenharmony_ci * check the length against the header size before reading the size field 1222e5b6d6dSopenharmony_ci */ 1232e5b6d6dSopenharmony_ci uprv_memset(&header, 0, sizeof(header)); 1242e5b6d6dSopenharmony_ci if(length<0) { 1252e5b6d6dSopenharmony_ci header.size=udata_readInt32(ds, inHeader->size); 1262e5b6d6dSopenharmony_ci } else if((length<(42*4) || length<(header.size=udata_readInt32(ds, inHeader->size)))) { 1272e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=3): too few bytes (%d after header) for collation data\n", 1282e5b6d6dSopenharmony_ci length); 1292e5b6d6dSopenharmony_ci *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; 1302e5b6d6dSopenharmony_ci return 0; 1312e5b6d6dSopenharmony_ci } 1322e5b6d6dSopenharmony_ci 1332e5b6d6dSopenharmony_ci header.magic=ds->readUInt32(inHeader->magic); 1342e5b6d6dSopenharmony_ci if(!( 1352e5b6d6dSopenharmony_ci header.magic==UCOL_HEADER_MAGIC && 1362e5b6d6dSopenharmony_ci inHeader->formatVersion[0]==3 /*&& 1372e5b6d6dSopenharmony_ci inHeader->formatVersion[1]>=0*/ 1382e5b6d6dSopenharmony_ci )) { 1392e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=3): magic 0x%08x or format version %02x.%02x is not a collation binary\n", 1402e5b6d6dSopenharmony_ci header.magic, 1412e5b6d6dSopenharmony_ci inHeader->formatVersion[0], inHeader->formatVersion[1]); 1422e5b6d6dSopenharmony_ci *pErrorCode=U_UNSUPPORTED_ERROR; 1432e5b6d6dSopenharmony_ci return 0; 1442e5b6d6dSopenharmony_ci } 1452e5b6d6dSopenharmony_ci 1462e5b6d6dSopenharmony_ci if(inHeader->isBigEndian!=ds->inIsBigEndian || inHeader->charSetFamily!=ds->inCharset) { 1472e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=3): endianness %d or charset %d does not match the swapper\n", 1482e5b6d6dSopenharmony_ci inHeader->isBigEndian, inHeader->charSetFamily); 1492e5b6d6dSopenharmony_ci *pErrorCode=U_INVALID_FORMAT_ERROR; 1502e5b6d6dSopenharmony_ci return 0; 1512e5b6d6dSopenharmony_ci } 1522e5b6d6dSopenharmony_ci 1532e5b6d6dSopenharmony_ci if(length>=0) { 1542e5b6d6dSopenharmony_ci /* copy everything, takes care of data that needs no swapping */ 1552e5b6d6dSopenharmony_ci if(inBytes!=outBytes) { 1562e5b6d6dSopenharmony_ci uprv_memcpy(outBytes, inBytes, header.size); 1572e5b6d6dSopenharmony_ci } 1582e5b6d6dSopenharmony_ci 1592e5b6d6dSopenharmony_ci /* swap the necessary pieces in the order of their occurrence in the data */ 1602e5b6d6dSopenharmony_ci 1612e5b6d6dSopenharmony_ci /* read more of the UCATableHeader (the size field was read above) */ 1622e5b6d6dSopenharmony_ci header.options= ds->readUInt32(inHeader->options); 1632e5b6d6dSopenharmony_ci header.UCAConsts= ds->readUInt32(inHeader->UCAConsts); 1642e5b6d6dSopenharmony_ci header.contractionUCACombos= ds->readUInt32(inHeader->contractionUCACombos); 1652e5b6d6dSopenharmony_ci header.mappingPosition= ds->readUInt32(inHeader->mappingPosition); 1662e5b6d6dSopenharmony_ci header.expansion= ds->readUInt32(inHeader->expansion); 1672e5b6d6dSopenharmony_ci header.contractionIndex= ds->readUInt32(inHeader->contractionIndex); 1682e5b6d6dSopenharmony_ci header.contractionCEs= ds->readUInt32(inHeader->contractionCEs); 1692e5b6d6dSopenharmony_ci header.contractionSize= ds->readUInt32(inHeader->contractionSize); 1702e5b6d6dSopenharmony_ci header.endExpansionCE= ds->readUInt32(inHeader->endExpansionCE); 1712e5b6d6dSopenharmony_ci header.expansionCESize= ds->readUInt32(inHeader->expansionCESize); 1722e5b6d6dSopenharmony_ci header.endExpansionCECount= udata_readInt32(ds, inHeader->endExpansionCECount); 1732e5b6d6dSopenharmony_ci header.contractionUCACombosSize=udata_readInt32(ds, inHeader->contractionUCACombosSize); 1742e5b6d6dSopenharmony_ci header.scriptToLeadByte= ds->readUInt32(inHeader->scriptToLeadByte); 1752e5b6d6dSopenharmony_ci header.leadByteToScript= ds->readUInt32(inHeader->leadByteToScript); 1762e5b6d6dSopenharmony_ci 1772e5b6d6dSopenharmony_ci /* swap the 32-bit integers in the header */ 1782e5b6d6dSopenharmony_ci ds->swapArray32(ds, inHeader, (int32_t)((const char *)&inHeader->jamoSpecial-(const char *)inHeader), 1792e5b6d6dSopenharmony_ci outHeader, pErrorCode); 1802e5b6d6dSopenharmony_ci ds->swapArray32(ds, &(inHeader->scriptToLeadByte), sizeof(header.scriptToLeadByte) + sizeof(header.leadByteToScript), 1812e5b6d6dSopenharmony_ci &(outHeader->scriptToLeadByte), pErrorCode); 1822e5b6d6dSopenharmony_ci /* set the output platform properties */ 1832e5b6d6dSopenharmony_ci outHeader->isBigEndian=ds->outIsBigEndian; 1842e5b6d6dSopenharmony_ci outHeader->charSetFamily=ds->outCharset; 1852e5b6d6dSopenharmony_ci 1862e5b6d6dSopenharmony_ci /* swap the options */ 1872e5b6d6dSopenharmony_ci if(header.options!=0) { 1882e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes+header.options, header.expansion-header.options, 1892e5b6d6dSopenharmony_ci outBytes+header.options, pErrorCode); 1902e5b6d6dSopenharmony_ci } 1912e5b6d6dSopenharmony_ci 1922e5b6d6dSopenharmony_ci /* swap the expansions */ 1932e5b6d6dSopenharmony_ci if(header.mappingPosition!=0 && header.expansion!=0) { 1942e5b6d6dSopenharmony_ci if(header.contractionIndex!=0) { 1952e5b6d6dSopenharmony_ci /* expansions bounded by contractions */ 1962e5b6d6dSopenharmony_ci count=header.contractionIndex-header.expansion; 1972e5b6d6dSopenharmony_ci } else { 1982e5b6d6dSopenharmony_ci /* no contractions: expansions bounded by the main trie */ 1992e5b6d6dSopenharmony_ci count=header.mappingPosition-header.expansion; 2002e5b6d6dSopenharmony_ci } 2012e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes+header.expansion, (int32_t)count, 2022e5b6d6dSopenharmony_ci outBytes+header.expansion, pErrorCode); 2032e5b6d6dSopenharmony_ci } 2042e5b6d6dSopenharmony_ci 2052e5b6d6dSopenharmony_ci /* swap the contractions */ 2062e5b6d6dSopenharmony_ci if(header.contractionSize!=0) { 2072e5b6d6dSopenharmony_ci /* contractionIndex: UChar[] */ 2082e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes+header.contractionIndex, header.contractionSize*2, 2092e5b6d6dSopenharmony_ci outBytes+header.contractionIndex, pErrorCode); 2102e5b6d6dSopenharmony_ci 2112e5b6d6dSopenharmony_ci /* contractionCEs: CEs[] */ 2122e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes+header.contractionCEs, header.contractionSize*4, 2132e5b6d6dSopenharmony_ci outBytes+header.contractionCEs, pErrorCode); 2142e5b6d6dSopenharmony_ci } 2152e5b6d6dSopenharmony_ci 2162e5b6d6dSopenharmony_ci /* swap the main trie */ 2172e5b6d6dSopenharmony_ci if(header.mappingPosition!=0) { 2182e5b6d6dSopenharmony_ci count=header.endExpansionCE-header.mappingPosition; 2192e5b6d6dSopenharmony_ci utrie_swap(ds, inBytes+header.mappingPosition, (int32_t)count, 2202e5b6d6dSopenharmony_ci outBytes+header.mappingPosition, pErrorCode); 2212e5b6d6dSopenharmony_ci } 2222e5b6d6dSopenharmony_ci 2232e5b6d6dSopenharmony_ci /* swap the max expansion table */ 2242e5b6d6dSopenharmony_ci if(header.endExpansionCECount!=0) { 2252e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes+header.endExpansionCE, header.endExpansionCECount*4, 2262e5b6d6dSopenharmony_ci outBytes+header.endExpansionCE, pErrorCode); 2272e5b6d6dSopenharmony_ci } 2282e5b6d6dSopenharmony_ci 2292e5b6d6dSopenharmony_ci /* expansionCESize, unsafeCP, contrEndCP: uint8_t[], no need to swap */ 2302e5b6d6dSopenharmony_ci 2312e5b6d6dSopenharmony_ci /* swap UCA constants */ 2322e5b6d6dSopenharmony_ci if(header.UCAConsts!=0) { 2332e5b6d6dSopenharmony_ci /* 2342e5b6d6dSopenharmony_ci * if UCAConsts!=0 then contractionUCACombos because we are swapping 2352e5b6d6dSopenharmony_ci * the UCA data file, and we know that the UCA contains contractions 2362e5b6d6dSopenharmony_ci */ 2372e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes+header.UCAConsts, header.contractionUCACombos-header.UCAConsts, 2382e5b6d6dSopenharmony_ci outBytes+header.UCAConsts, pErrorCode); 2392e5b6d6dSopenharmony_ci } 2402e5b6d6dSopenharmony_ci 2412e5b6d6dSopenharmony_ci /* swap UCA contractions */ 2422e5b6d6dSopenharmony_ci if(header.contractionUCACombosSize!=0) { 2432e5b6d6dSopenharmony_ci count=header.contractionUCACombosSize*inHeader->contractionUCACombosWidth*U_SIZEOF_UCHAR; 2442e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes+header.contractionUCACombos, (int32_t)count, 2452e5b6d6dSopenharmony_ci outBytes+header.contractionUCACombos, pErrorCode); 2462e5b6d6dSopenharmony_ci } 2472e5b6d6dSopenharmony_ci 2482e5b6d6dSopenharmony_ci /* swap the script to lead bytes */ 2492e5b6d6dSopenharmony_ci if(header.scriptToLeadByte!=0) { 2502e5b6d6dSopenharmony_ci int indexCount = ds->readUInt16(*((uint16_t*)(inBytes+header.scriptToLeadByte))); // each entry = 2 * uint16 2512e5b6d6dSopenharmony_ci int dataCount = ds->readUInt16(*((uint16_t*)(inBytes+header.scriptToLeadByte + 2))); // each entry = uint16 2522e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes+header.scriptToLeadByte, 2532e5b6d6dSopenharmony_ci 4 + (4 * indexCount) + (2 * dataCount), 2542e5b6d6dSopenharmony_ci outBytes+header.scriptToLeadByte, pErrorCode); 2552e5b6d6dSopenharmony_ci } 2562e5b6d6dSopenharmony_ci 2572e5b6d6dSopenharmony_ci /* swap the lead byte to scripts */ 2582e5b6d6dSopenharmony_ci if(header.leadByteToScript!=0) { 2592e5b6d6dSopenharmony_ci int indexCount = ds->readUInt16(*((uint16_t*)(inBytes+header.leadByteToScript))); // each entry = uint16 2602e5b6d6dSopenharmony_ci int dataCount = ds->readUInt16(*((uint16_t*)(inBytes+header.leadByteToScript + 2))); // each entry = uint16 2612e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes+header.leadByteToScript, 2622e5b6d6dSopenharmony_ci 4 + (2 * indexCount) + (2 * dataCount), 2632e5b6d6dSopenharmony_ci outBytes+header.leadByteToScript, pErrorCode); 2642e5b6d6dSopenharmony_ci } 2652e5b6d6dSopenharmony_ci } 2662e5b6d6dSopenharmony_ci 2672e5b6d6dSopenharmony_ci return header.size; 2682e5b6d6dSopenharmony_ci} 2692e5b6d6dSopenharmony_ci 2702e5b6d6dSopenharmony_ci// swap formatVersion 4 or 5 ----------------------------------------------- *** 2712e5b6d6dSopenharmony_ci 2722e5b6d6dSopenharmony_ci// The following are copied from CollationDataReader, trading an awkward copy of constants 2732e5b6d6dSopenharmony_ci// for an awkward relocation of the i18n collationdatareader.h file into the common library. 2742e5b6d6dSopenharmony_ci// Keep them in sync! 2752e5b6d6dSopenharmony_ci 2762e5b6d6dSopenharmony_cienum { 2772e5b6d6dSopenharmony_ci IX_INDEXES_LENGTH, // 0 2782e5b6d6dSopenharmony_ci IX_OPTIONS, 2792e5b6d6dSopenharmony_ci IX_RESERVED2, 2802e5b6d6dSopenharmony_ci IX_RESERVED3, 2812e5b6d6dSopenharmony_ci 2822e5b6d6dSopenharmony_ci IX_JAMO_CE32S_START, // 4 2832e5b6d6dSopenharmony_ci IX_REORDER_CODES_OFFSET, 2842e5b6d6dSopenharmony_ci IX_REORDER_TABLE_OFFSET, 2852e5b6d6dSopenharmony_ci IX_TRIE_OFFSET, 2862e5b6d6dSopenharmony_ci 2872e5b6d6dSopenharmony_ci IX_RESERVED8_OFFSET, // 8 2882e5b6d6dSopenharmony_ci IX_CES_OFFSET, 2892e5b6d6dSopenharmony_ci IX_RESERVED10_OFFSET, 2902e5b6d6dSopenharmony_ci IX_CE32S_OFFSET, 2912e5b6d6dSopenharmony_ci 2922e5b6d6dSopenharmony_ci IX_ROOT_ELEMENTS_OFFSET, // 12 2932e5b6d6dSopenharmony_ci IX_CONTEXTS_OFFSET, 2942e5b6d6dSopenharmony_ci IX_UNSAFE_BWD_OFFSET, 2952e5b6d6dSopenharmony_ci IX_FAST_LATIN_TABLE_OFFSET, 2962e5b6d6dSopenharmony_ci 2972e5b6d6dSopenharmony_ci IX_SCRIPTS_OFFSET, // 16 2982e5b6d6dSopenharmony_ci IX_COMPRESSIBLE_BYTES_OFFSET, 2992e5b6d6dSopenharmony_ci IX_RESERVED18_OFFSET, 3002e5b6d6dSopenharmony_ci IX_TOTAL_SIZE 3012e5b6d6dSopenharmony_ci}; 3022e5b6d6dSopenharmony_ci 3032e5b6d6dSopenharmony_ciint32_t 3042e5b6d6dSopenharmony_ciswapFormatVersion4(const UDataSwapper *ds, 3052e5b6d6dSopenharmony_ci const void *inData, int32_t length, void *outData, 3062e5b6d6dSopenharmony_ci UErrorCode &errorCode) { 3072e5b6d6dSopenharmony_ci if(U_FAILURE(errorCode)) { return 0; } 3082e5b6d6dSopenharmony_ci 3092e5b6d6dSopenharmony_ci const uint8_t *inBytes=(const uint8_t *)inData; 3102e5b6d6dSopenharmony_ci uint8_t *outBytes=(uint8_t *)outData; 3112e5b6d6dSopenharmony_ci 3122e5b6d6dSopenharmony_ci const int32_t *inIndexes=(const int32_t *)inBytes; 3132e5b6d6dSopenharmony_ci int32_t indexes[IX_TOTAL_SIZE+1]; 3142e5b6d6dSopenharmony_ci 3152e5b6d6dSopenharmony_ci // Need at least IX_INDEXES_LENGTH and IX_OPTIONS. 3162e5b6d6dSopenharmony_ci if(0<=length && length<8) { 3172e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=4): too few bytes " 3182e5b6d6dSopenharmony_ci "(%d after header) for collation data\n", 3192e5b6d6dSopenharmony_ci length); 3202e5b6d6dSopenharmony_ci errorCode=U_INDEX_OUTOFBOUNDS_ERROR; 3212e5b6d6dSopenharmony_ci return 0; 3222e5b6d6dSopenharmony_ci } 3232e5b6d6dSopenharmony_ci 3242e5b6d6dSopenharmony_ci int32_t indexesLength=indexes[0]=udata_readInt32(ds, inIndexes[0]); 3252e5b6d6dSopenharmony_ci if(0<=length && length<(indexesLength*4)) { 3262e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=4): too few bytes " 3272e5b6d6dSopenharmony_ci "(%d after header) for collation data\n", 3282e5b6d6dSopenharmony_ci length); 3292e5b6d6dSopenharmony_ci errorCode=U_INDEX_OUTOFBOUNDS_ERROR; 3302e5b6d6dSopenharmony_ci return 0; 3312e5b6d6dSopenharmony_ci } 3322e5b6d6dSopenharmony_ci 3332e5b6d6dSopenharmony_ci for(int32_t i=1; i<=IX_TOTAL_SIZE && i<indexesLength; ++i) { 3342e5b6d6dSopenharmony_ci indexes[i]=udata_readInt32(ds, inIndexes[i]); 3352e5b6d6dSopenharmony_ci } 3362e5b6d6dSopenharmony_ci for(int32_t i=indexesLength; i<=IX_TOTAL_SIZE; ++i) { 3372e5b6d6dSopenharmony_ci indexes[i]=-1; 3382e5b6d6dSopenharmony_ci } 3392e5b6d6dSopenharmony_ci inIndexes=NULL; // Make sure we do not accidentally use these instead of indexes[]. 3402e5b6d6dSopenharmony_ci 3412e5b6d6dSopenharmony_ci // Get the total length of the data. 3422e5b6d6dSopenharmony_ci int32_t size; 3432e5b6d6dSopenharmony_ci if(indexesLength>IX_TOTAL_SIZE) { 3442e5b6d6dSopenharmony_ci size=indexes[IX_TOTAL_SIZE]; 3452e5b6d6dSopenharmony_ci } else if(indexesLength>IX_REORDER_CODES_OFFSET) { 3462e5b6d6dSopenharmony_ci size=indexes[indexesLength-1]; 3472e5b6d6dSopenharmony_ci } else { 3482e5b6d6dSopenharmony_ci size=indexesLength*4; 3492e5b6d6dSopenharmony_ci } 3502e5b6d6dSopenharmony_ci if(length<0) { return size; } 3512e5b6d6dSopenharmony_ci 3522e5b6d6dSopenharmony_ci if(length<size) { 3532e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=4): too few bytes " 3542e5b6d6dSopenharmony_ci "(%d after header) for collation data\n", 3552e5b6d6dSopenharmony_ci length); 3562e5b6d6dSopenharmony_ci errorCode=U_INDEX_OUTOFBOUNDS_ERROR; 3572e5b6d6dSopenharmony_ci return 0; 3582e5b6d6dSopenharmony_ci } 3592e5b6d6dSopenharmony_ci 3602e5b6d6dSopenharmony_ci // Copy the data for inaccessible bytes and arrays of bytes. 3612e5b6d6dSopenharmony_ci if(inBytes!=outBytes) { 3622e5b6d6dSopenharmony_ci uprv_memcpy(outBytes, inBytes, size); 3632e5b6d6dSopenharmony_ci } 3642e5b6d6dSopenharmony_ci 3652e5b6d6dSopenharmony_ci // Swap the int32_t indexes[]. 3662e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes, indexesLength * 4, outBytes, &errorCode); 3672e5b6d6dSopenharmony_ci 3682e5b6d6dSopenharmony_ci // The following is a modified version of CollationDataReader::read(). 3692e5b6d6dSopenharmony_ci // Here we use indexes[] not inIndexes[] because 3702e5b6d6dSopenharmony_ci // the inIndexes[] may not be in this machine's endianness. 3712e5b6d6dSopenharmony_ci int32_t index; // one of the indexes[] slots 3722e5b6d6dSopenharmony_ci int32_t offset; // byte offset for the index part 3732e5b6d6dSopenharmony_ci // int32_t length; // number of bytes in the index part 3742e5b6d6dSopenharmony_ci 3752e5b6d6dSopenharmony_ci index = IX_REORDER_CODES_OFFSET; 3762e5b6d6dSopenharmony_ci offset = indexes[index]; 3772e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 3782e5b6d6dSopenharmony_ci if(length > 0) { 3792e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes + offset, length, outBytes + offset, &errorCode); 3802e5b6d6dSopenharmony_ci } 3812e5b6d6dSopenharmony_ci 3822e5b6d6dSopenharmony_ci // Skip the IX_REORDER_TABLE_OFFSET byte array. 3832e5b6d6dSopenharmony_ci 3842e5b6d6dSopenharmony_ci index = IX_TRIE_OFFSET; 3852e5b6d6dSopenharmony_ci offset = indexes[index]; 3862e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 3872e5b6d6dSopenharmony_ci if(length > 0) { 3882e5b6d6dSopenharmony_ci utrie2_swap(ds, inBytes + offset, length, outBytes + offset, &errorCode); 3892e5b6d6dSopenharmony_ci } 3902e5b6d6dSopenharmony_ci 3912e5b6d6dSopenharmony_ci index = IX_RESERVED8_OFFSET; 3922e5b6d6dSopenharmony_ci offset = indexes[index]; 3932e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 3942e5b6d6dSopenharmony_ci if(length > 0) { 3952e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=4): unknown data at IX_RESERVED8_OFFSET\n", length); 3962e5b6d6dSopenharmony_ci errorCode = U_UNSUPPORTED_ERROR; 3972e5b6d6dSopenharmony_ci return 0; 3982e5b6d6dSopenharmony_ci } 3992e5b6d6dSopenharmony_ci 4002e5b6d6dSopenharmony_ci index = IX_CES_OFFSET; 4012e5b6d6dSopenharmony_ci offset = indexes[index]; 4022e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4032e5b6d6dSopenharmony_ci if(length > 0) { 4042e5b6d6dSopenharmony_ci ds->swapArray64(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4052e5b6d6dSopenharmony_ci } 4062e5b6d6dSopenharmony_ci 4072e5b6d6dSopenharmony_ci index = IX_RESERVED10_OFFSET; 4082e5b6d6dSopenharmony_ci offset = indexes[index]; 4092e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4102e5b6d6dSopenharmony_ci if(length > 0) { 4112e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=4): unknown data at IX_RESERVED10_OFFSET\n", length); 4122e5b6d6dSopenharmony_ci errorCode = U_UNSUPPORTED_ERROR; 4132e5b6d6dSopenharmony_ci return 0; 4142e5b6d6dSopenharmony_ci } 4152e5b6d6dSopenharmony_ci 4162e5b6d6dSopenharmony_ci index = IX_CE32S_OFFSET; 4172e5b6d6dSopenharmony_ci offset = indexes[index]; 4182e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4192e5b6d6dSopenharmony_ci if(length > 0) { 4202e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4212e5b6d6dSopenharmony_ci } 4222e5b6d6dSopenharmony_ci 4232e5b6d6dSopenharmony_ci index = IX_ROOT_ELEMENTS_OFFSET; 4242e5b6d6dSopenharmony_ci offset = indexes[index]; 4252e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4262e5b6d6dSopenharmony_ci if(length > 0) { 4272e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4282e5b6d6dSopenharmony_ci } 4292e5b6d6dSopenharmony_ci 4302e5b6d6dSopenharmony_ci index = IX_CONTEXTS_OFFSET; 4312e5b6d6dSopenharmony_ci offset = indexes[index]; 4322e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4332e5b6d6dSopenharmony_ci if(length > 0) { 4342e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4352e5b6d6dSopenharmony_ci } 4362e5b6d6dSopenharmony_ci 4372e5b6d6dSopenharmony_ci index = IX_UNSAFE_BWD_OFFSET; 4382e5b6d6dSopenharmony_ci offset = indexes[index]; 4392e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4402e5b6d6dSopenharmony_ci if(length > 0) { 4412e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4422e5b6d6dSopenharmony_ci } 4432e5b6d6dSopenharmony_ci 4442e5b6d6dSopenharmony_ci index = IX_FAST_LATIN_TABLE_OFFSET; 4452e5b6d6dSopenharmony_ci offset = indexes[index]; 4462e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4472e5b6d6dSopenharmony_ci if(length > 0) { 4482e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4492e5b6d6dSopenharmony_ci } 4502e5b6d6dSopenharmony_ci 4512e5b6d6dSopenharmony_ci index = IX_SCRIPTS_OFFSET; 4522e5b6d6dSopenharmony_ci offset = indexes[index]; 4532e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4542e5b6d6dSopenharmony_ci if(length > 0) { 4552e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes + offset, length, outBytes + offset, &errorCode); 4562e5b6d6dSopenharmony_ci } 4572e5b6d6dSopenharmony_ci 4582e5b6d6dSopenharmony_ci // Skip the IX_COMPRESSIBLE_BYTES_OFFSET byte array. 4592e5b6d6dSopenharmony_ci 4602e5b6d6dSopenharmony_ci index = IX_RESERVED18_OFFSET; 4612e5b6d6dSopenharmony_ci offset = indexes[index]; 4622e5b6d6dSopenharmony_ci length = indexes[index + 1] - offset; 4632e5b6d6dSopenharmony_ci if(length > 0) { 4642e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(formatVersion=4): unknown data at IX_RESERVED18_OFFSET\n", length); 4652e5b6d6dSopenharmony_ci errorCode = U_UNSUPPORTED_ERROR; 4662e5b6d6dSopenharmony_ci return 0; 4672e5b6d6dSopenharmony_ci } 4682e5b6d6dSopenharmony_ci 4692e5b6d6dSopenharmony_ci return size; 4702e5b6d6dSopenharmony_ci} 4712e5b6d6dSopenharmony_ci 4722e5b6d6dSopenharmony_ci} // namespace 4732e5b6d6dSopenharmony_ci 4742e5b6d6dSopenharmony_ci/* swap ICU collation data like ucadata.icu */ 4752e5b6d6dSopenharmony_ciU_CAPI int32_t U_EXPORT2 4762e5b6d6dSopenharmony_ciucol_swap(const UDataSwapper *ds, 4772e5b6d6dSopenharmony_ci const void *inData, int32_t length, void *outData, 4782e5b6d6dSopenharmony_ci UErrorCode *pErrorCode) { 4792e5b6d6dSopenharmony_ci if(U_FAILURE(*pErrorCode)) { return 0; } 4802e5b6d6dSopenharmony_ci 4812e5b6d6dSopenharmony_ci /* udata_swapDataHeader checks the arguments */ 4822e5b6d6dSopenharmony_ci int32_t headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorCode); 4832e5b6d6dSopenharmony_ci if(U_FAILURE(*pErrorCode)) { 4842e5b6d6dSopenharmony_ci // Try to swap the old format version which did not have a standard data header. 4852e5b6d6dSopenharmony_ci *pErrorCode=U_ZERO_ERROR; 4862e5b6d6dSopenharmony_ci return swapFormatVersion3(ds, inData, length, outData, pErrorCode); 4872e5b6d6dSopenharmony_ci } 4882e5b6d6dSopenharmony_ci 4892e5b6d6dSopenharmony_ci /* check data format and format version */ 4902e5b6d6dSopenharmony_ci const UDataInfo &info=*(const UDataInfo *)((const char *)inData+4); 4912e5b6d6dSopenharmony_ci if(!( 4922e5b6d6dSopenharmony_ci info.dataFormat[0]==0x55 && // dataFormat="UCol" 4932e5b6d6dSopenharmony_ci info.dataFormat[1]==0x43 && 4942e5b6d6dSopenharmony_ci info.dataFormat[2]==0x6f && 4952e5b6d6dSopenharmony_ci info.dataFormat[3]==0x6c && 4962e5b6d6dSopenharmony_ci (3<=info.formatVersion[0] && info.formatVersion[0]<=5) 4972e5b6d6dSopenharmony_ci )) { 4982e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swap(): data format %02x.%02x.%02x.%02x " 4992e5b6d6dSopenharmony_ci "(format version %02x.%02x) is not recognized as collation data\n", 5002e5b6d6dSopenharmony_ci info.dataFormat[0], info.dataFormat[1], 5012e5b6d6dSopenharmony_ci info.dataFormat[2], info.dataFormat[3], 5022e5b6d6dSopenharmony_ci info.formatVersion[0], info.formatVersion[1]); 5032e5b6d6dSopenharmony_ci *pErrorCode=U_UNSUPPORTED_ERROR; 5042e5b6d6dSopenharmony_ci return 0; 5052e5b6d6dSopenharmony_ci } 5062e5b6d6dSopenharmony_ci 5072e5b6d6dSopenharmony_ci inData=(const char *)inData+headerSize; 5082e5b6d6dSopenharmony_ci if(length>=0) { length-=headerSize; } 5092e5b6d6dSopenharmony_ci outData=(char *)outData+headerSize; 5102e5b6d6dSopenharmony_ci int32_t collationSize; 5112e5b6d6dSopenharmony_ci if(info.formatVersion[0]>=4) { 5122e5b6d6dSopenharmony_ci collationSize=swapFormatVersion4(ds, inData, length, outData, *pErrorCode); 5132e5b6d6dSopenharmony_ci } else { 5142e5b6d6dSopenharmony_ci collationSize=swapFormatVersion3(ds, inData, length, outData, pErrorCode); 5152e5b6d6dSopenharmony_ci } 5162e5b6d6dSopenharmony_ci if(U_SUCCESS(*pErrorCode)) { 5172e5b6d6dSopenharmony_ci return headerSize+collationSize; 5182e5b6d6dSopenharmony_ci } else { 5192e5b6d6dSopenharmony_ci return 0; 5202e5b6d6dSopenharmony_ci } 5212e5b6d6dSopenharmony_ci} 5222e5b6d6dSopenharmony_ci 5232e5b6d6dSopenharmony_ci/* swap inverse UCA collation data (invuca.icu) */ 5242e5b6d6dSopenharmony_ciU_CAPI int32_t U_EXPORT2 5252e5b6d6dSopenharmony_ciucol_swapInverseUCA(const UDataSwapper *ds, 5262e5b6d6dSopenharmony_ci const void *inData, int32_t length, void *outData, 5272e5b6d6dSopenharmony_ci UErrorCode *pErrorCode) { 5282e5b6d6dSopenharmony_ci const UDataInfo *pInfo; 5292e5b6d6dSopenharmony_ci int32_t headerSize; 5302e5b6d6dSopenharmony_ci 5312e5b6d6dSopenharmony_ci const uint8_t *inBytes; 5322e5b6d6dSopenharmony_ci uint8_t *outBytes; 5332e5b6d6dSopenharmony_ci 5342e5b6d6dSopenharmony_ci const InverseUCATableHeader *inHeader; 5352e5b6d6dSopenharmony_ci InverseUCATableHeader *outHeader; 5362e5b6d6dSopenharmony_ci InverseUCATableHeader header={ 0,0,0,0,0,{0,0,0,0},{0,0,0,0,0,0,0,0} }; 5372e5b6d6dSopenharmony_ci 5382e5b6d6dSopenharmony_ci /* udata_swapDataHeader checks the arguments */ 5392e5b6d6dSopenharmony_ci headerSize=udata_swapDataHeader(ds, inData, length, outData, pErrorCode); 5402e5b6d6dSopenharmony_ci if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { 5412e5b6d6dSopenharmony_ci return 0; 5422e5b6d6dSopenharmony_ci } 5432e5b6d6dSopenharmony_ci 5442e5b6d6dSopenharmony_ci /* check data format and format version */ 5452e5b6d6dSopenharmony_ci pInfo=(const UDataInfo *)((const char *)inData+4); 5462e5b6d6dSopenharmony_ci if(!( 5472e5b6d6dSopenharmony_ci pInfo->dataFormat[0]==0x49 && /* dataFormat="InvC" */ 5482e5b6d6dSopenharmony_ci pInfo->dataFormat[1]==0x6e && 5492e5b6d6dSopenharmony_ci pInfo->dataFormat[2]==0x76 && 5502e5b6d6dSopenharmony_ci pInfo->dataFormat[3]==0x43 && 5512e5b6d6dSopenharmony_ci pInfo->formatVersion[0]==2 && 5522e5b6d6dSopenharmony_ci pInfo->formatVersion[1]>=1 5532e5b6d6dSopenharmony_ci )) { 5542e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swapInverseUCA(): data format %02x.%02x.%02x.%02x (format version %02x.%02x) is not an inverse UCA collation file\n", 5552e5b6d6dSopenharmony_ci pInfo->dataFormat[0], pInfo->dataFormat[1], 5562e5b6d6dSopenharmony_ci pInfo->dataFormat[2], pInfo->dataFormat[3], 5572e5b6d6dSopenharmony_ci pInfo->formatVersion[0], pInfo->formatVersion[1]); 5582e5b6d6dSopenharmony_ci *pErrorCode=U_UNSUPPORTED_ERROR; 5592e5b6d6dSopenharmony_ci return 0; 5602e5b6d6dSopenharmony_ci } 5612e5b6d6dSopenharmony_ci 5622e5b6d6dSopenharmony_ci inBytes=(const uint8_t *)inData+headerSize; 5632e5b6d6dSopenharmony_ci outBytes=(uint8_t *)outData+headerSize; 5642e5b6d6dSopenharmony_ci 5652e5b6d6dSopenharmony_ci inHeader=(const InverseUCATableHeader *)inBytes; 5662e5b6d6dSopenharmony_ci outHeader=(InverseUCATableHeader *)outBytes; 5672e5b6d6dSopenharmony_ci 5682e5b6d6dSopenharmony_ci /* 5692e5b6d6dSopenharmony_ci * The inverse UCA collation binary must contain at least the InverseUCATableHeader, 5702e5b6d6dSopenharmony_ci * starting with its size field. 5712e5b6d6dSopenharmony_ci * sizeof(UCATableHeader)==8*4 in ICU 2.8 5722e5b6d6dSopenharmony_ci * check the length against the header size before reading the size field 5732e5b6d6dSopenharmony_ci */ 5742e5b6d6dSopenharmony_ci if(length<0) { 5752e5b6d6dSopenharmony_ci header.byteSize=udata_readInt32(ds, inHeader->byteSize); 5762e5b6d6dSopenharmony_ci } else if( 5772e5b6d6dSopenharmony_ci ((length-headerSize)<(8*4) || 5782e5b6d6dSopenharmony_ci (uint32_t)(length-headerSize)<(header.byteSize=udata_readInt32(ds, inHeader->byteSize))) 5792e5b6d6dSopenharmony_ci ) { 5802e5b6d6dSopenharmony_ci udata_printError(ds, "ucol_swapInverseUCA(): too few bytes (%d after header) for inverse UCA collation data\n", 5812e5b6d6dSopenharmony_ci length); 5822e5b6d6dSopenharmony_ci *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; 5832e5b6d6dSopenharmony_ci return 0; 5842e5b6d6dSopenharmony_ci } 5852e5b6d6dSopenharmony_ci 5862e5b6d6dSopenharmony_ci if(length>=0) { 5872e5b6d6dSopenharmony_ci /* copy everything, takes care of data that needs no swapping */ 5882e5b6d6dSopenharmony_ci if(inBytes!=outBytes) { 5892e5b6d6dSopenharmony_ci uprv_memcpy(outBytes, inBytes, header.byteSize); 5902e5b6d6dSopenharmony_ci } 5912e5b6d6dSopenharmony_ci 5922e5b6d6dSopenharmony_ci /* swap the necessary pieces in the order of their occurrence in the data */ 5932e5b6d6dSopenharmony_ci 5942e5b6d6dSopenharmony_ci /* read more of the InverseUCATableHeader (the byteSize field was read above) */ 5952e5b6d6dSopenharmony_ci header.tableSize= ds->readUInt32(inHeader->tableSize); 5962e5b6d6dSopenharmony_ci header.contsSize= ds->readUInt32(inHeader->contsSize); 5972e5b6d6dSopenharmony_ci header.table= ds->readUInt32(inHeader->table); 5982e5b6d6dSopenharmony_ci header.conts= ds->readUInt32(inHeader->conts); 5992e5b6d6dSopenharmony_ci 6002e5b6d6dSopenharmony_ci /* swap the 32-bit integers in the header */ 6012e5b6d6dSopenharmony_ci ds->swapArray32(ds, inHeader, 5*4, outHeader, pErrorCode); 6022e5b6d6dSopenharmony_ci 6032e5b6d6dSopenharmony_ci /* swap the inverse table; tableSize counts uint32_t[3] rows */ 6042e5b6d6dSopenharmony_ci ds->swapArray32(ds, inBytes+header.table, header.tableSize*3*4, 6052e5b6d6dSopenharmony_ci outBytes+header.table, pErrorCode); 6062e5b6d6dSopenharmony_ci 6072e5b6d6dSopenharmony_ci /* swap the continuation table; contsSize counts UChars */ 6082e5b6d6dSopenharmony_ci ds->swapArray16(ds, inBytes+header.conts, header.contsSize*U_SIZEOF_UCHAR, 6092e5b6d6dSopenharmony_ci outBytes+header.conts, pErrorCode); 6102e5b6d6dSopenharmony_ci } 6112e5b6d6dSopenharmony_ci 6122e5b6d6dSopenharmony_ci return headerSize+header.byteSize; 6132e5b6d6dSopenharmony_ci} 6142e5b6d6dSopenharmony_ci 6152e5b6d6dSopenharmony_ci#endif /* #if !UCONFIG_NO_COLLATION */ 616