Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <rtl/tencinfo.h>
21 : #include <tools/tenccvt.hxx>
22 :
23 0 : rtl_TextEncoding GetExtendedCompatibilityTextEncoding( rtl_TextEncoding eEncoding )
24 : {
25 : // Latin1
26 0 : if ( eEncoding == RTL_TEXTENCODING_ISO_8859_1 )
27 0 : return RTL_TEXTENCODING_MS_1252;
28 : // Turkey
29 0 : else if ( eEncoding == RTL_TEXTENCODING_ISO_8859_9 )
30 0 : return RTL_TEXTENCODING_MS_1254;
31 : else
32 0 : return eEncoding;
33 : }
34 :
35 0 : rtl_TextEncoding GetExtendedTextEncoding( rtl_TextEncoding eEncoding )
36 : {
37 : // Cyr
38 0 : if ( eEncoding == RTL_TEXTENCODING_ISO_8859_5 )
39 0 : return RTL_TEXTENCODING_MS_1251;
40 : // Greek (2 Characters different: A1 (0x2018/0x0385), A2 (0x2019/0x0386) -
41 : // so it is handled in this function and not in GetExtendedCompatibilityTextEncoding)
42 0 : else if ( eEncoding == RTL_TEXTENCODING_ISO_8859_7 )
43 0 : return RTL_TEXTENCODING_MS_1253;
44 : // East-Europe - Latin2
45 0 : else if ( eEncoding == RTL_TEXTENCODING_ISO_8859_2 )
46 0 : return RTL_TEXTENCODING_MS_1250;
47 : // Latin-15 - Latin 1 mit Euro-Sign
48 0 : else if ( eEncoding == RTL_TEXTENCODING_ISO_8859_15 )
49 0 : return RTL_TEXTENCODING_MS_1252;
50 : else
51 0 : return GetExtendedCompatibilityTextEncoding( eEncoding );
52 : }
53 :
54 0 : rtl_TextEncoding GetOneByteTextEncoding( rtl_TextEncoding eEncoding )
55 : {
56 : rtl_TextEncodingInfo aTextEncInfo;
57 0 : aTextEncInfo.StructSize = sizeof( aTextEncInfo );
58 0 : if ( rtl_getTextEncodingInfo( eEncoding, &aTextEncInfo ) )
59 : {
60 0 : if ( aTextEncInfo.MaximumCharSize > 1 )
61 0 : return RTL_TEXTENCODING_MS_1252;
62 : else
63 0 : return eEncoding;
64 : }
65 : else
66 0 : return RTL_TEXTENCODING_MS_1252;
67 : }
68 :
69 0 : rtl_TextEncoding GetSOLoadTextEncoding( rtl_TextEncoding eEncoding )
70 : {
71 0 : return GetExtendedCompatibilityTextEncoding( GetOneByteTextEncoding( eEncoding ) );
72 : }
73 :
74 0 : rtl_TextEncoding GetSOStoreTextEncoding( rtl_TextEncoding eEncoding )
75 : {
76 0 : return GetExtendedTextEncoding( GetOneByteTextEncoding( eEncoding ) );
77 : }
78 :
79 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|