/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/* pMatchStr must match with all characters in pCompStr */ staticbool Impl_matchString( constchar* pCompStr, constchar* pMatchStr )
{ /* We test only for end in MatchStr, because the last 0 character from */ /* pCompStr is unequal a character in MatchStr, so the loop terminates */ while ( *pMatchStr )
{ if ( *pCompStr != *pMatchStr ) returnfalse;
pData = Impl_getTextEncodingData( eTextEncoding ); if ( !pData )
{ /* HACK: For not implemented encoding, because not all
calls handle the errors */ if ( pEncInfo->StructSize < 5 ) returnfalse;
pEncInfo->MinimumCharSize = 1;
if ( pEncInfo->StructSize < 6 ) returntrue;
pEncInfo->MaximumCharSize = 1;
if ( pEncInfo->StructSize < 7 ) returntrue;
pEncInfo->AverageCharSize = 1;
if ( pEncInfo->StructSize < 12 ) returntrue;
pEncInfo->Flags = 0;
returnfalse;
}
if ( pEncInfo->StructSize < 5 ) returnfalse;
pEncInfo->MinimumCharSize = pData->mnMinCharSize;
if ( pEncInfo->StructSize < 6 ) returntrue;
pEncInfo->MaximumCharSize = pData->mnMaxCharSize;
if ( pEncInfo->StructSize < 7 ) returntrue;
pEncInfo->AverageCharSize = pData->mnAveCharSize;
if ( pEncInfo->StructSize < 12 ) returntrue;
pEncInfo->Flags = pData->mnInfoFlags;
rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( constchar* pUnixCharset )
{ /* See <ftp://ftp.x.org/pub/DOCS/registry>, section 14 ("Font Charset * (Registry and Encoding) Names").
*/
/* All Identifiers in the tables are lower case The function search */ /* for the first matching string in the tables. */ /* Sort order: unique (first 14, then 1), important */
/* found part separator */ if ( pSecondPart )
{ /* Search for the part tab */ const ImplStrFirstPartCharsetDef* pFirstPartData = aUnixCharsetFirstPartTab; while ( pFirstPartData->mpCharsetStr )
{ if ( Impl_matchString( pFirstPart, pFirstPartData->mpCharsetStr ) )
{ /* Search for the charset in the second part tab */ const ImplStrCharsetDef* pData = pFirstPartData->mpSecondPartTab; while ( pData->mpCharsetStr )
{ if ( Impl_matchString( pSecondPart, pData->mpCharsetStr ) )
{ break;
}
pData++;
}
/* use default encoding for first part */
eEncoding = pData->meTextEncoding; break;
}
/* Alloc Buffer and map to lower case and remove non alphanumeric chars */
std::unique_ptr<char[]> pBuf(newchar[nBufLen]);
Impl_toAsciiLowerAndRemoveNonAlphanumeric( pMimeCharset, pBuf.get() );
/* Search for equal in the VIP table */ while ( pData->mpCharsetStr )
{ if ( strcmp( pBuf.get(), pData->mpCharsetStr ) == 0 )
{
eEncoding = pData->meTextEncoding; break;
}
pData++;
}
/* Search for matching in the mime table */ if ( eEncoding == RTL_TEXTENCODING_DONTKNOW )
{
pData = aMimeCharsetTab; while ( pData->mpCharsetStr )
{ if ( Impl_matchString( pBuf.get(), pData->mpCharsetStr ) )
{
eEncoding = pData->meTextEncoding; break;
}
rtl_TextEncoding SAL_CALL
rtl_getTextEncodingFromWindowsCodePage(sal_uInt32 nCodePage)
{ switch (nCodePage)
{ case 42: return RTL_TEXTENCODING_SYMBOL; case 437: return RTL_TEXTENCODING_IBM_437; case 708: return RTL_TEXTENCODING_ISO_8859_6; case 737: return RTL_TEXTENCODING_IBM_737; case 775: return RTL_TEXTENCODING_IBM_775; case 850: return RTL_TEXTENCODING_IBM_850; case 852: return RTL_TEXTENCODING_IBM_852; case 855: return RTL_TEXTENCODING_IBM_855; case 857: return RTL_TEXTENCODING_IBM_857; case 860: return RTL_TEXTENCODING_IBM_860; case 861: return RTL_TEXTENCODING_IBM_861; case 862: return RTL_TEXTENCODING_IBM_862; case 863: return RTL_TEXTENCODING_IBM_863; case 864: return RTL_TEXTENCODING_IBM_864; case 865: return RTL_TEXTENCODING_IBM_865; case 866: return RTL_TEXTENCODING_IBM_866; case 869: return RTL_TEXTENCODING_IBM_869; case 874: return RTL_TEXTENCODING_MS_874; case 932: return RTL_TEXTENCODING_MS_932; case 936: return RTL_TEXTENCODING_MS_936; case 949: return RTL_TEXTENCODING_MS_949; case 950: return RTL_TEXTENCODING_MS_950; case 1250: return RTL_TEXTENCODING_MS_1250; case 1251: return RTL_TEXTENCODING_MS_1251; case 1252: return RTL_TEXTENCODING_MS_1252; case 1253: return RTL_TEXTENCODING_MS_1253; case 1254: return RTL_TEXTENCODING_MS_1254; case 1255: return RTL_TEXTENCODING_MS_1255; case 1256: return RTL_TEXTENCODING_MS_1256; case 1257: return RTL_TEXTENCODING_MS_1257; case 1258: return RTL_TEXTENCODING_MS_1258; case 1361: return RTL_TEXTENCODING_MS_1361; case 10000: return RTL_TEXTENCODING_APPLE_ROMAN; case 10001: return RTL_TEXTENCODING_APPLE_JAPANESE; case 10002: return RTL_TEXTENCODING_APPLE_CHINTRAD; case 10003: return RTL_TEXTENCODING_APPLE_KOREAN; case 10004: return RTL_TEXTENCODING_APPLE_ARABIC; case 10005: return RTL_TEXTENCODING_APPLE_HEBREW; case 10006: return RTL_TEXTENCODING_APPLE_GREEK; case 10007: return RTL_TEXTENCODING_APPLE_CYRILLIC; case 10008: return RTL_TEXTENCODING_APPLE_CHINSIMP; case 10010: return RTL_TEXTENCODING_APPLE_ROMANIAN; case 10017: return RTL_TEXTENCODING_APPLE_UKRAINIAN; case 10029: return RTL_TEXTENCODING_APPLE_CENTEURO; case 10079: return RTL_TEXTENCODING_APPLE_ICELAND; case 10081: return RTL_TEXTENCODING_APPLE_TURKISH; case 10082: return RTL_TEXTENCODING_APPLE_CROATIAN; case 20127: return RTL_TEXTENCODING_ASCII_US; case 20866: return RTL_TEXTENCODING_KOI8_R; case 21866: return RTL_TEXTENCODING_KOI8_U; case 28591: return RTL_TEXTENCODING_ISO_8859_1; case 28592: return RTL_TEXTENCODING_ISO_8859_2; case 28593: return RTL_TEXTENCODING_ISO_8859_3; case 28594: return RTL_TEXTENCODING_ISO_8859_4; case 28595: return RTL_TEXTENCODING_ISO_8859_5; case 28596: return RTL_TEXTENCODING_ISO_8859_6; case 28597: return RTL_TEXTENCODING_ISO_8859_7; case 28598: return RTL_TEXTENCODING_ISO_8859_8; case 28599: return RTL_TEXTENCODING_ISO_8859_9; case 28605: return RTL_TEXTENCODING_ISO_8859_15; case 50220: return RTL_TEXTENCODING_ISO_2022_JP; case 50225: return RTL_TEXTENCODING_ISO_2022_KR; case 51932: return RTL_TEXTENCODING_EUC_JP; case 51936: return RTL_TEXTENCODING_EUC_CN; case 51949: return RTL_TEXTENCODING_EUC_KR; case 57002: return RTL_TEXTENCODING_ISCII_DEVANAGARI; case 65000: return RTL_TEXTENCODING_UTF7; case 65001: return RTL_TEXTENCODING_UTF8; default: return RTL_TEXTENCODING_DONTKNOW;
}
}
sal_uInt32 SAL_CALL
rtl_getWindowsCodePageFromTextEncoding(rtl_TextEncoding nEncoding)
{ switch (nEncoding)
{ case RTL_TEXTENCODING_SYMBOL: return 42; case RTL_TEXTENCODING_IBM_437: return 437; /* case RTL_TEXTENCODING_ISO_8859_6: return 708; */ case RTL_TEXTENCODING_IBM_737: return 737; case RTL_TEXTENCODING_IBM_775: return 775; case RTL_TEXTENCODING_IBM_850: return 850; case RTL_TEXTENCODING_IBM_852: return 852; case RTL_TEXTENCODING_IBM_855: return 855; case RTL_TEXTENCODING_IBM_857: return 857; case RTL_TEXTENCODING_IBM_860: return 860; case RTL_TEXTENCODING_IBM_861: return 861; case RTL_TEXTENCODING_IBM_862: return 862; case RTL_TEXTENCODING_IBM_863: return 863; case RTL_TEXTENCODING_IBM_864: return 864; case RTL_TEXTENCODING_IBM_865: return 865; case RTL_TEXTENCODING_IBM_866: return 866; case RTL_TEXTENCODING_IBM_869: return 869; case RTL_TEXTENCODING_MS_874: return 874; case RTL_TEXTENCODING_MS_932: return 932; case RTL_TEXTENCODING_MS_936: return 936; case RTL_TEXTENCODING_MS_949: return 949; case RTL_TEXTENCODING_MS_950: return 950; case RTL_TEXTENCODING_MS_1250: return 1250; case RTL_TEXTENCODING_MS_1251: return 1251; case RTL_TEXTENCODING_MS_1252: return 1252; case RTL_TEXTENCODING_MS_1253: return 1253; case RTL_TEXTENCODING_MS_1254: return 1254; case RTL_TEXTENCODING_MS_1255: return 1255; case RTL_TEXTENCODING_MS_1256: return 1256; case RTL_TEXTENCODING_MS_1257: return 1257; case RTL_TEXTENCODING_MS_1258: return 1258; case RTL_TEXTENCODING_MS_1361: return 1361; case RTL_TEXTENCODING_APPLE_ROMAN: return 10000; case RTL_TEXTENCODING_APPLE_JAPANESE: return 10001; case RTL_TEXTENCODING_APPLE_CHINTRAD: return 10002; case RTL_TEXTENCODING_APPLE_KOREAN: return 10003; case RTL_TEXTENCODING_APPLE_ARABIC: return 10004; case RTL_TEXTENCODING_APPLE_HEBREW: return 10005; case RTL_TEXTENCODING_APPLE_GREEK: return 10006; case RTL_TEXTENCODING_APPLE_CYRILLIC: return 10007; case RTL_TEXTENCODING_APPLE_CHINSIMP: return 10008; case RTL_TEXTENCODING_APPLE_ROMANIAN: return 10010; case RTL_TEXTENCODING_APPLE_UKRAINIAN: return 10017; case RTL_TEXTENCODING_APPLE_CENTEURO: return 10029; case RTL_TEXTENCODING_APPLE_ICELAND: return 10079; case RTL_TEXTENCODING_APPLE_TURKISH: return 10081; case RTL_TEXTENCODING_APPLE_CROATIAN: return 10082; case RTL_TEXTENCODING_ASCII_US: return 20127; case RTL_TEXTENCODING_KOI8_R: return 20866; case RTL_TEXTENCODING_KOI8_U: return 21866; case RTL_TEXTENCODING_ISO_8859_1: return 28591; case RTL_TEXTENCODING_ISO_8859_2: return 28592; case RTL_TEXTENCODING_ISO_8859_3: return 28593; case RTL_TEXTENCODING_ISO_8859_4: return 28594; case RTL_TEXTENCODING_ISO_8859_5: return 28595; case RTL_TEXTENCODING_ISO_8859_6: return 28596; case RTL_TEXTENCODING_ISO_8859_7: return 28597; case RTL_TEXTENCODING_ISO_8859_8: return 28598; case RTL_TEXTENCODING_ISO_8859_9: return 28599; case RTL_TEXTENCODING_ISO_8859_15: return 28605; case RTL_TEXTENCODING_ISO_2022_JP: return 50220; case RTL_TEXTENCODING_ISO_2022_KR: return 50225; case RTL_TEXTENCODING_EUC_JP: return 51932; case RTL_TEXTENCODING_EUC_CN: return 51936; case RTL_TEXTENCODING_EUC_KR: return 51949; case RTL_TEXTENCODING_ISCII_DEVANAGARI: return 57002; case RTL_TEXTENCODING_UTF7: return 65000; case RTL_TEXTENCODING_UTF8: return 65001; default: return 0;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.