1*565d668cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*565d668cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*565d668cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*565d668cSAndrew Rist * distributed with this work for additional information 6*565d668cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*565d668cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*565d668cSAndrew Rist * "License"); you may not use this file except in compliance 9*565d668cSAndrew Rist * with the License. You may obtain a copy of the License at 10*565d668cSAndrew Rist * 11*565d668cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*565d668cSAndrew Rist * 13*565d668cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*565d668cSAndrew Rist * software distributed under the License is distributed on an 15*565d668cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*565d668cSAndrew Rist * KIND, either express or implied. See the License for the 17*565d668cSAndrew Rist * specific language governing permissions and limitations 18*565d668cSAndrew Rist * under the License. 19*565d668cSAndrew Rist * 20*565d668cSAndrew Rist *************************************************************/ 21*565d668cSAndrew Rist 22*565d668cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_sal_textenc_convertsinglebytetobmpunicode_hxx 25cdf0e10cSrcweir #define INCLUDED_sal_textenc_convertsinglebytetobmpunicode_hxx 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "tenchelp.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "sal/types.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <cstddef> 32cdf0e10cSrcweir 33cdf0e10cSrcweir /// @HTML 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace rtl { namespace textenc { 36cdf0e10cSrcweir 37cdf0e10cSrcweir /** 38cdf0e10cSrcweir Maps a range of BMP Unicode code points to individual bytes. 39cdf0e10cSrcweir 40cdf0e10cSrcweir @see rtl::textenc::BmpUnicodeToSingleByteConverterData 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir struct BmpUnicodeToSingleByteRange { 43cdf0e10cSrcweir /** 44cdf0e10cSrcweir The start of the range of BMP Unicode code points. 45cdf0e10cSrcweir */ 46cdf0e10cSrcweir sal_Unicode unicode; 47cdf0e10cSrcweir 48cdf0e10cSrcweir /** 49cdf0e10cSrcweir The extend of the range of BMP Unicode code points. 50cdf0e10cSrcweir 51cdf0e10cSrcweir <p>The range covers <code>unicode</code> to <code>unicode + range</code>, 52cdf0e10cSrcweir inclusive. It is an error if <code>unicode + range</code> is greater 53cdf0e10cSrcweir than <code>0xFFFF</code>.</p> 54cdf0e10cSrcweir */ 55cdf0e10cSrcweir sal_uInt8 range; 56cdf0e10cSrcweir 57cdf0e10cSrcweir /** 58cdf0e10cSrcweir The start of the corresponding range of individual bytes. 59cdf0e10cSrcweir 60cdf0e10cSrcweir <p>It is an error if <code>byte + range</code> is greater than 61cdf0e10cSrcweir <code>0xFF</code>.</p> 62cdf0e10cSrcweir */ 63cdf0e10cSrcweir sal_uInt8 byte; 64cdf0e10cSrcweir }; 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** 67cdf0e10cSrcweir Data to convert between BMP Unicode and a single-byte character set. 68cdf0e10cSrcweir 69cdf0e10cSrcweir <p>Only supports conversions where each legal unit from the single-byte 70cdf0e10cSrcweir character set has one or more mappings to individual BMP Unicode code points 71cdf0e10cSrcweir that are neither noncharacters nor surrogates.</p> 72cdf0e10cSrcweir 73cdf0e10cSrcweir @see rtl_textenc_convertSingleByteToBmpUnicode 74cdf0e10cSrcweir @see rtl_textenc_convertBmpUnicodeToSingleByte 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir struct BmpUnicodeToSingleByteConverterData { 77cdf0e10cSrcweir /** 78cdf0e10cSrcweir Mapping from the single-byte character set to BMP Unicode code points. 79cdf0e10cSrcweir 80cdf0e10cSrcweir <p>Illegal units from the single-byte character set are mapped to 81cdf0e10cSrcweir <code>0xFFFF</code>.</p> 82cdf0e10cSrcweir */ 83cdf0e10cSrcweir sal_Unicode byteToUnicode[256]; 84cdf0e10cSrcweir 85cdf0e10cSrcweir /** 86cdf0e10cSrcweir The number of Unicode-to-byte conversion ranges. 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir std::size_t unicodeToByteEntries; 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** 91cdf0e10cSrcweir The array of Unicode-to-byte conversion ranges, sorted by increasing 92cdf0e10cSrcweir <code>unicode</code> values. 93cdf0e10cSrcweir 94cdf0e10cSrcweir <p>The ranges may not overlap.</p> 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir BmpUnicodeToSingleByteRange const * unicodeToByte; 97cdf0e10cSrcweir }; 98cdf0e10cSrcweir 99cdf0e10cSrcweir } } 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** 102cdf0e10cSrcweir Function to convert from a single-byte character set to BMP Unicode. 103cdf0e10cSrcweir 104cdf0e10cSrcweir @see ImplConvertToUnicodeProc 105cdf0e10cSrcweir */ 106cdf0e10cSrcweir extern "C" sal_Size rtl_textenc_convertSingleByteToBmpUnicode( 107cdf0e10cSrcweir ImplTextConverterData const * data, void * context, sal_Char const * srcBuf, 108cdf0e10cSrcweir sal_Size srcBytes, sal_Unicode * destBuf, sal_Size destChars, 109cdf0e10cSrcweir sal_uInt32 flags, sal_uInt32 * info, sal_Size * srcCvtBytes); 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** 112cdf0e10cSrcweir Function to convert from BMP Unicode to a single-byte character set. 113cdf0e10cSrcweir 114cdf0e10cSrcweir @see ImplConvertToTextProc 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir extern "C" sal_Size rtl_textenc_convertBmpUnicodeToSingleByte( 117cdf0e10cSrcweir ImplTextConverterData const * data, void * context, 118cdf0e10cSrcweir sal_Unicode const * srcBuf, sal_Size srcChars, sal_Char * destBuf, 119cdf0e10cSrcweir sal_Size destBytes, sal_uInt32 flags, sal_uInt32 * info, 120cdf0e10cSrcweir sal_Size * srcCvtChars); 121cdf0e10cSrcweir 122cdf0e10cSrcweir #endif 123