diff options
author | Stephan Bergmann <sb@openoffice.org> | 2002-03-19 14:15:42 +0000 |
---|---|---|
committer | Stephan Bergmann <sb@openoffice.org> | 2002-03-19 14:15:42 +0000 |
commit | d2cf878b2db96d153a0d529f3c327f53cf2d857e (patch) | |
tree | 91306812b78766822dfee53d0b76c5a2abc322c4 | |
parent | cb5e8821d4aa7094132b12b44597f1d5ced7511c (diff) |
#98247# Remove RTL_TEXTENCODING_STD_COUNT.
-rw-r--r-- | sal/inc/rtl/tencinfo.h | 30 | ||||
-rw-r--r-- | sal/inc/rtl/textenc.h | 9 | ||||
-rw-r--r-- | sal/rtl/source/string.c | 13 | ||||
-rw-r--r-- | sal/rtl/source/ustring.c | 13 | ||||
-rw-r--r-- | sal/textenc/tencinfo.c | 19 | ||||
-rwxr-xr-x | sal/util/sal.map | 2 |
6 files changed, 64 insertions, 22 deletions
diff --git a/sal/inc/rtl/tencinfo.h b/sal/inc/rtl/tencinfo.h index 3852ac78079d..ce3da086879e 100644 --- a/sal/inc/rtl/tencinfo.h +++ b/sal/inc/rtl/tencinfo.h @@ -2,9 +2,9 @@ * * $RCSfile: tencinfo.h,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: sb $ $Date: 2001-10-29 13:27:54 $ + * last change: $Author: sb $ $Date: 2002-03-19 15:08:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -129,6 +129,19 @@ typedef struct _rtl_TextEncodingInfo sal_uInt32 Flags; } rtl_TextEncodingInfo; +/** Determine whether a text encoding uses single octets as basic units of + information (and can thus be used with the conversion routines in + rtl/textcvt.h). + + @param nEncoding + Any rtl_TextEncoding value. + + @return + True if the given encoding uses single octets as basic units of + information, false otherwise. + */ +sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding); + /** Return information about a text encoding. @param eTextEncoding @@ -187,6 +200,19 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pU */ sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ); +/** Map from a text encoding to a corresponding MIME charset name, if + available (see <http://www.iana.org/assignments/character-sets>). + + @param nEncoding + Any rtl_TextEncoding value. + + @return + The (preferred) MIME charset name corresponding to the given encoding, or + NULL if none is available. + */ +char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(rtl_TextEncoding + nEncoding); + /** Map from a text encoding to the best matching MIME charset. @param eTextEncoding diff --git a/sal/inc/rtl/textenc.h b/sal/inc/rtl/textenc.h index 46b541aae253..68f04a4ca2b0 100644 --- a/sal/inc/rtl/textenc.h +++ b/sal/inc/rtl/textenc.h @@ -2,9 +2,9 @@ * * $RCSfile: textenc.h,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: sb $ $Date: 2002-03-18 14:41:28 $ + * last change: $Author: sb $ $Date: 2002-03-19 15:08:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -174,8 +174,9 @@ typedef sal_uInt16 rtl_TextEncoding; #define RTL_TEXTENCODING_GB_18030 (RTL_TEXTENC_CAST( 85 )) #define RTL_TEXTENCODING_BIG5_HKSCS (RTL_TEXTENC_CAST( 86 )) #define RTL_TEXTENCODING_TIS_620 (RTL_TEXTENC_CAST( 87 )) - -#define RTL_TEXTENCODING_STD_COUNT (RTL_TEXTENC_CAST( 88 )) +/* ATTENTION! Whenever some encoding is added here, make sure to update + * rtl_isOctetEncoding in tencinfo.c. + */ #define RTL_TEXTENCODING_USER_START (RTL_TEXTENC_CAST( 0x8000 )) #define RTL_TEXTENCODING_USER_END (RTL_TEXTENC_CAST( 0xEFFF )) diff --git a/sal/rtl/source/string.c b/sal/rtl/source/string.c index 263579e8bdc4..efb7d25ae8a9 100644 --- a/sal/rtl/source/string.c +++ b/sal/rtl/source/string.c @@ -2,9 +2,9 @@ * * $RCSfile: string.c,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: th $ $Date: 2001-05-09 12:54:32 $ + * last change: $Author: sb $ $Date: 2002-03-19 15:12:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,8 @@ #include <rtl/string.h> #endif +#include "rtl/tencinfo.h" + /* ======================================================================= */ /* static data to be referenced by all empty strings @@ -189,11 +191,8 @@ void SAL_CALL rtl_uString2String( rtl_String** ppThis, rtl_TextEncoding eTextEncoding, sal_uInt32 nCvtFlags ) { - OSL_ENSURE( (eTextEncoding != 9) && - (eTextEncoding != RTL_TEXTENCODING_DONTKNOW) && - (eTextEncoding != RTL_TEXTENCODING_UCS2) && - (eTextEncoding != RTL_TEXTENCODING_UCS4), - "rtl_uString2String() - Wrong TextEncoding" ); + OSL_ENSURE(rtl_isOctetTextEncoding(eTextEncoding), + "rtl_uString2String() - Wrong TextEncoding"); if ( !nULen ) rtl_string_new( ppThis ); diff --git a/sal/rtl/source/ustring.c b/sal/rtl/source/ustring.c index 42e542874e9e..64475b91a2e0 100644 --- a/sal/rtl/source/ustring.c +++ b/sal/rtl/source/ustring.c @@ -2,9 +2,9 @@ * * $RCSfile: ustring.c,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: th $ $Date: 2001-07-30 17:46:21 $ + * last change: $Author: sb $ $Date: 2002-03-19 15:12:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,8 @@ #include <rtl/ustring.h> #endif +#include "rtl/tencinfo.h" + /* ======================================================================= */ /* static data to be referenced by all empty strings @@ -414,11 +416,8 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis, rtl_TextEncoding eTextEncoding, sal_uInt32 nCvtFlags ) { - OSL_ENSURE( (eTextEncoding != 9) && - (eTextEncoding != RTL_TEXTENCODING_DONTKNOW) && - (eTextEncoding != RTL_TEXTENCODING_UCS2) && - (eTextEncoding != RTL_TEXTENCODING_UCS4), - "rtl_string2UString() - Wrong TextEncoding" ); + OSL_ENSURE(rtl_isOctetTextEncoding(eTextEncoding), + "rtl_string2UString() - Wrong TextEncoding" ); if ( !nLen ) rtl_uString_new( ppThis ); diff --git a/sal/textenc/tencinfo.c b/sal/textenc/tencinfo.c index 1478fb4d167e..9383be7d9759 100644 --- a/sal/textenc/tencinfo.c +++ b/sal/textenc/tencinfo.c @@ -2,9 +2,9 @@ * * $RCSfile: tencinfo.c,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: sb $ $Date: 2002-03-18 14:43:42 $ + * last change: $Author: sb $ $Date: 2002-03-19 15:11:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,13 @@ #define INCLUDED_STRING_H #endif +sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding) +{ + return nEncoding > RTL_TEXTENCODING_DONTKNOW + && nEncoding <= RTL_TEXTENCODING_TIS_620 /* always update this! */ + && nEncoding != 9; /* RTL_TEXTENCODING_SYSTEM */ +} + /* ======================================================================= */ static void Impl_toAsciiLower( const sal_Char* pName, sal_Char* pBuf ) @@ -988,6 +995,14 @@ const sal_Char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncodin /* ----------------------------------------------------------------------- */ +char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(rtl_TextEncoding + nEncoding) +{ + ImplTextEncodingData const * p = Impl_getTextEncodingData(nEncoding); + return p && (p->mnInfoFlags & RTL_TEXTENCODING_INFO_MIME) != 0 ? + p->mpBestMimeCharset : NULL; +} + const sal_Char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) { const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding ); diff --git a/sal/util/sal.map b/sal/util/sal.map index 0148eab1cf2e..ba9d7bee9536 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -331,11 +331,13 @@ UDK_3_0_0 { rtl_destroyUnicodeToTextContext; rtl_resetUnicodeToTextContext; rtl_convertUnicodeToText; + rtl_isOctetTextEncoding; rtl_getTextEncodingInfo; rtl_getTextEncodingFromWindowsCharset; rtl_getTextEncodingFromUnixCharset; rtl_getTextEncodingFromMimeCharset; rtl_getBestWindowsCharsetFromTextEncoding; + rtl_getMimeCharsetFromTextEncoding; rtl_getBestMimeCharsetFromTextEncoding; rtl_getBestUnixCharsetFromTextEncoding; rtl_allocateZeroMemory; |