1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_sal_textenc_convertsinglebytetobmpunicode_hxx 29 #define INCLUDED_sal_textenc_convertsinglebytetobmpunicode_hxx 30 31 #include "tenchelp.h" 32 33 #include "sal/types.h" 34 35 #include <cstddef> 36 37 /// @HTML 38 39 namespace rtl { namespace textenc { 40 41 /** 42 Maps a range of BMP Unicode code points to individual bytes. 43 44 @see rtl::textenc::BmpUnicodeToSingleByteConverterData 45 */ 46 struct BmpUnicodeToSingleByteRange { 47 /** 48 The start of the range of BMP Unicode code points. 49 */ 50 sal_Unicode unicode; 51 52 /** 53 The extend of the range of BMP Unicode code points. 54 55 <p>The range covers <code>unicode</code> to <code>unicode + range</code>, 56 inclusive. It is an error if <code>unicode + range</code> is greater 57 than <code>0xFFFF</code>.</p> 58 */ 59 sal_uInt8 range; 60 61 /** 62 The start of the corresponding range of individual bytes. 63 64 <p>It is an error if <code>byte + range</code> is greater than 65 <code>0xFF</code>.</p> 66 */ 67 sal_uInt8 byte; 68 }; 69 70 /** 71 Data to convert between BMP Unicode and a single-byte character set. 72 73 <p>Only supports conversions where each legal unit from the single-byte 74 character set has one or more mappings to individual BMP Unicode code points 75 that are neither noncharacters nor surrogates.</p> 76 77 @see rtl_textenc_convertSingleByteToBmpUnicode 78 @see rtl_textenc_convertBmpUnicodeToSingleByte 79 */ 80 struct BmpUnicodeToSingleByteConverterData { 81 /** 82 Mapping from the single-byte character set to BMP Unicode code points. 83 84 <p>Illegal units from the single-byte character set are mapped to 85 <code>0xFFFF</code>.</p> 86 */ 87 sal_Unicode byteToUnicode[256]; 88 89 /** 90 The number of Unicode-to-byte conversion ranges. 91 */ 92 std::size_t unicodeToByteEntries; 93 94 /** 95 The array of Unicode-to-byte conversion ranges, sorted by increasing 96 <code>unicode</code> values. 97 98 <p>The ranges may not overlap.</p> 99 */ 100 BmpUnicodeToSingleByteRange const * unicodeToByte; 101 }; 102 103 } } 104 105 /** 106 Function to convert from a single-byte character set to BMP Unicode. 107 108 @see ImplConvertToUnicodeProc 109 */ 110 extern "C" sal_Size rtl_textenc_convertSingleByteToBmpUnicode( 111 ImplTextConverterData const * data, void * context, sal_Char const * srcBuf, 112 sal_Size srcBytes, sal_Unicode * destBuf, sal_Size destChars, 113 sal_uInt32 flags, sal_uInt32 * info, sal_Size * srcCvtBytes); 114 115 /** 116 Function to convert from BMP Unicode to a single-byte character set. 117 118 @see ImplConvertToTextProc 119 */ 120 extern "C" sal_Size rtl_textenc_convertBmpUnicodeToSingleByte( 121 ImplTextConverterData const * data, void * context, 122 sal_Unicode const * srcBuf, sal_Size srcChars, sal_Char * destBuf, 123 sal_Size destBytes, sal_uInt32 flags, sal_uInt32 * info, 124 sal_Size * srcCvtChars); 125 126 #endif 127