1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
30 /****************** I N C L U D E S **************************************/
35 #ifndef _TABLE_HXX //autogen
36 #include <tools/table.hxx>
40 #include <tools/solar.h>
41 #include <rsctools.hxx>
43 #include <rtl/textcvt.h>
44 #include <rtl/textenc.h>
45 #include <rtl/alloc.h>
47 /*************************************************************************
49 |* RscChar::MakeChar()
51 |* Beschreibung Der String wird nach C-Konvention umgesetzt
52 |* Ersterstellung MM 20.03.91
53 |* Letzte Aenderung MM 20.03.91
55 *************************************************************************/
56 char * RscChar::MakeUTF8( char * pStr
, sal_uInt16 nTextEncoding
)
58 sal_Size nMaxUniCodeBuf
= strlen( pStr
) + 1;
59 if( nMaxUniCodeBuf
* 6 > 0x0FFFFF )
62 char * pOrgStr
= new char[ nMaxUniCodeBuf
];
63 sal_uInt32 nOrgLen
= 0;
110 if( '0' <= *pStr
&& '7' >= *pStr
)
112 sal_uInt16 nChar
= 0;
114 while( '0' <= *pStr
&& '7' >= *pStr
&& i
!= 3 )
116 nChar
= nChar
* 8 + (sal_uInt8
)*pStr
- (sal_uInt8
)'0';
122 // Wert zu gross, oder kein 3 Ziffern
129 else if( 'x' == *pStr
)
131 sal_uInt16 nChar
= 0;
134 while( isxdigit( *pStr
) && i
!= 2 )
136 if( isdigit( *pStr
) )
137 nChar
= nChar
* 16 + (sal_uInt8
)*pStr
- (sal_uInt8
)'0';
138 else if( isupper( *pStr
) )
139 nChar
= nChar
* 16 + (sal_uInt8
)*pStr
- (sal_uInt8
)'A' +10;
141 nChar
= nChar
* 16 + (sal_uInt8
)*pStr
- (sal_uInt8
)'a' +10;
155 pOrgStr
[ nOrgLen
++ ] = c
;
160 sal_Unicode
* pUniCode
= new sal_Unicode
[ nMaxUniCodeBuf
];
161 rtl_TextToUnicodeConverter hConv
= rtl_createTextToUnicodeConverter( nTextEncoding
);
164 sal_Size nSrcCvtBytes
;
165 sal_Size nUniSize
= rtl_convertTextToUnicode( hConv
, 0,
167 pUniCode
, nMaxUniCodeBuf
,
168 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT
169 | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT
170 | RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT
171 | RTL_TEXTTOUNICODE_FLAGS_FLUSH
,
175 rtl_destroyTextToUnicodeConverter( hConv
);
176 delete[] pOrgStr
, pOrgStr
= 0;
178 hConv
= rtl_createUnicodeToTextConverter( RTL_TEXTENCODING_UTF8
);
179 // factor fo 6 is the maximum size of an UNICODE character as utf8
180 char * pUtf8
= (char *)rtl_allocateMemory( nUniSize
* 6 );
181 rtl_convertUnicodeToText( hConv
, 0,
184 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT
185 | RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT
186 | RTL_UNICODETOTEXT_FLAGS_FLUSH
,
190 rtl_destroyTextToUnicodeConverter( hConv
);
191 delete[] pUniCode
, pUniCode
= 0;