Kaydet (Commit) 4976dd85 authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Stephan Bergmann

Introduce characters utilities in rtl/character.hxx

Signed-off-by: Stephan Bergmann <sbergman@redhat.com>, with slight modifications
to sal/inc/rtl/character.hxx:
* Replaced "#pragma once" with explicit include guard for now.
* Missing includes.
* Cosmetic clean-up.

Change-Id: I94d01cd4e766f92c70f941839a67101fa2c97654
üst 5d67919a
...@@ -20,26 +20,7 @@ ...@@ -20,26 +20,7 @@
#include <tools/errcode.hxx> #include <tools/errcode.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <basic/sbx.hxx> #include <basic/sbx.hxx>
#include <rtl/character.hxx>
static bool isAlpha( sal_Unicode c )
{
bool bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
return bRet;
}
static bool isDigit( sal_Unicode c )
{
bool bRet = (c >= '0' && c <= '9');
return bRet;
}
static bool isAlphaNumeric( sal_Unicode c )
{
bool bRet = isDigit( c ) || isAlpha( c );
return bRet;
}
static SbxVariable* Element static SbxVariable* Element
...@@ -72,7 +53,7 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym ) ...@@ -72,7 +53,7 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym )
else else
{ {
// A symbol had to begin with a alphabetic character or an underline // A symbol had to begin with a alphabetic character or an underline
if( !isAlpha( *p ) && *p != '_' ) if( !rtl::isAsciiAlpha( *p ) && *p != '_' )
{ {
SbxBase::SetError( SbxERR_SYNTAX ); SbxBase::SetError( SbxERR_SYNTAX );
} }
...@@ -80,7 +61,7 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym ) ...@@ -80,7 +61,7 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym )
{ {
rSym = p; rSym = p;
// The it can contain alphabetic characters, numbers or underlines // The it can contain alphabetic characters, numbers or underlines
while( *p && (isAlphaNumeric( *p ) || *p == '_') ) while( *p && (rtl::isAsciiAlphanumeric( *p ) || *p == '_') )
{ {
p++, nLen++; p++, nLen++;
} }
...@@ -103,7 +84,7 @@ static SbxVariable* QualifiedName ...@@ -103,7 +84,7 @@ static SbxVariable* QualifiedName
SbxVariableRef refVar; SbxVariableRef refVar;
const sal_Unicode* p = SkipWhitespace( *ppBuf ); const sal_Unicode* p = SkipWhitespace( *ppBuf );
if( isAlpha( *p ) || *p == '_' || *p == '[' ) if( rtl::isAsciiAlpha( *p ) || *p == '_' || *p == '[' )
{ {
// Read in the element // Read in the element
refVar = Element( pObj, pGbl, &p, t ); refVar = Element( pObj, pGbl, &p, t );
...@@ -139,8 +120,8 @@ static SbxVariable* Operand ...@@ -139,8 +120,8 @@ static SbxVariable* Operand
{ {
SbxVariableRef refVar( new SbxVariable ); SbxVariableRef refVar( new SbxVariable );
const sal_Unicode* p = SkipWhitespace( *ppBuf ); const sal_Unicode* p = SkipWhitespace( *ppBuf );
if( !bVar && ( isDigit( *p ) if( !bVar && ( rtl::isAsciiDigit( *p )
|| ( *p == '.' && isDigit( *( p+1 ) ) ) || ( *p == '.' && rtl::isAsciiDigit( *( p+1 ) ) )
|| *p == '-' || *p == '-'
|| *p == '&' ) ) || *p == '&' ) )
{ {
......
...@@ -32,6 +32,7 @@ $(eval $(call gb_ZipPackage_add_files,sal_odk_headers,inc/rtl,include/rtl,\ ...@@ -32,6 +32,7 @@ $(eval $(call gb_ZipPackage_add_files,sal_odk_headers,inc/rtl,include/rtl,\
rtl/bootstrap.hxx \ rtl/bootstrap.hxx \
rtl/byteseq.h \ rtl/byteseq.h \
rtl/byteseq.hxx \ rtl/byteseq.hxx \
rtl/character.hxx \
rtl/cipher.h \ rtl/cipher.h \
rtl/crc.h \ rtl/crc.h \
rtl/digest.h \ rtl/digest.h \
......
/* -*- 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 .
*/
#ifndef INCLUDED_RTL_CHARACTER_HXX
#define INCLUDED_RTL_CHARACTER_HXX
#include "sal/config.h"
#include "sal/types.h"
namespace rtl
{
/** Check for ASCII character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a ASCII character (0x00--0x7F).
@since LibreOffice 4.1
*/
inline bool isAscii(sal_uInt32 nUtf32)
{
return nUtf32 <= 0x7F;
}
/** Check for ASCII lower case character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a US-ASCII lower case alphabetic character
(ASCII 'a'--'z').
@since LibreOffice 4.1
*/
inline bool isAsciiLowerCase(sal_uInt32 nUtf32)
{
return nUtf32 >= 'a' && nUtf32 <= 'z';
}
/** Check for US-ASCII upper case character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a US-ASCII upper case alphabetic character
(US-ASCII 'A'--'Z').
@since LibreOffice 4.1
*/
inline bool isAsciiUpperCase(sal_uInt32 nUtf32)
{
return nUtf32 >= 'A' && nUtf32 <= 'Z';
}
/** Check for ASCII alphanumeric character.
@param nUtf32 Some UCS-4 character.
@return True if nUtf32 is a US-ASCII alphanumeric character
(ASCII '0'--'9', 'A'--'Z' or 'a'--'z').
@since LibreOffice 4.1
*/
inline bool isAsciiAlpha(sal_uInt32 nUtf32)
{
return isAsciiLowerCase(nUtf32) || isAsciiUpperCase(nUtf32);
}
/** Check for ASCII digit character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a ASCII (decimal) digit character
(ASCII '0'--'9').
@since LibreOffice 4.1
*/
inline bool isAsciiDigit(sal_uInt32 nUtf32)
{
return nUtf32 >= '0' && nUtf32 <= '9';
}
/** Check for US-ASCII alphanumeric character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a US-ASCII alphanumeric character (US-ASCII
'0'--'9', 'A'--'Z' or 'a'--'z').
@since LibreOffice 4.1
*/
inline bool isAsciiAlphanumeric(sal_uInt32 nUtf32)
{
return isAsciiDigit(nUtf32) || isAsciiAlpha(nUtf32);
}
/** Check for US-ASCII canonic hexadecimal digit character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a US-ASCII canonic (i.e., upper case)
hexadecimal digit character (US-ASCII '0'--'9' or 'A'--'F').
@since LibreOffice 4.1
*/
inline bool isAsciiCanonicHexDigit(sal_uInt32 nUtf32)
{
return isAsciiDigit(nUtf32) || (nUtf32 >= 'A' && nUtf32 <= 'F');
}
/** Check for US-ASCII hexadecimal digit character.
@param nUtf32 Some UCS-4 character.
@return True if nChar is a US-ASCII hexadecimal digit character (US-
ASCII '0'--'9', 'A'--'F', 'a'--'f').
@since LibreOffice 4.1
*/
inline bool isAsciiHexDigit(sal_uInt32 nUtf32)
{
return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f');
}
}//rtl namespace
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "rtl/alloc.h" #include "rtl/alloc.h"
#include "rtl/character.hxx"
#include "rtl/math.hxx" #include "rtl/math.hxx"
#include "rtl/strbuf.h" #include "rtl/strbuf.h"
#include "rtl/string.h" #include "rtl/string.h"
...@@ -689,13 +690,6 @@ inline bool long10Overflow( long& nExp, int nAdd ) ...@@ -689,13 +690,6 @@ inline bool long10Overflow( long& nExp, int nAdd )
return false; return false;
} }
// We are only concerned about ASCII arabic numerical digits here
template< typename CharT >
inline bool isDigit( CharT c )
{
return 0x30 <= c && c <= 0x39;
}
template< typename CharT > template< typename CharT >
inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
CharT cDecSeparator, CharT cGroupSeparator, CharT cDecSeparator, CharT cGroupSeparator,
...@@ -755,7 +749,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -755,7 +749,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
for (; p != pEnd; ++p) for (; p != pEnd; ++p)
{ {
CharT c = *p; CharT c = *p;
if (isDigit(c)) if (rtl::isAsciiDigit(c))
{ {
fVal = fVal * 10.0 + static_cast< double >( c - CharT('0') ); fVal = fVal * 10.0 + static_cast< double >( c - CharT('0') );
++nValExp; ++nValExp;
...@@ -783,7 +777,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -783,7 +777,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
for (; p != pEnd; ++p) for (; p != pEnd; ++p)
{ {
CharT c = *p; CharT c = *p;
if (!isDigit(c)) if (!rtl::isAsciiDigit(c))
break; break;
if ( nDigs < nSigs ) if ( nDigs < nSigs )
{ // further digits (more than nSigs) don't have any { // further digits (more than nSigs) don't have any
...@@ -821,7 +815,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -821,7 +815,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
if ( fVal == 0.0 ) if ( fVal == 0.0 )
{ // no matter what follows, zero stays zero, but carry on the { // no matter what follows, zero stays zero, but carry on the
// offset // offset
while (p != pEnd && isDigit(*p)) while (p != pEnd && rtl::isAsciiDigit(*p))
++p; ++p;
} }
else else
...@@ -831,7 +825,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -831,7 +825,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
for (; p != pEnd; ++p) for (; p != pEnd; ++p)
{ {
CharT c = *p; CharT c = *p;
if (!isDigit(c)) if (!rtl::isAsciiDigit(c))
break; break;
int i = c - CharT('0'); int i = c - CharT('0');
if ( long10Overflow( nExp, i ) ) if ( long10Overflow( nExp, i ) )
...@@ -876,7 +870,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -876,7 +870,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
fVal = HUGE_VAL; fVal = HUGE_VAL;
eStatus = rtl_math_ConversionStatus_OutOfRange; eStatus = rtl_math_ConversionStatus_OutOfRange;
// Eat any further digits: // Eat any further digits:
while (p != pEnd && isDigit(*p)) while (p != pEnd && rtl::isAsciiDigit(*p))
++p; ++p;
} }
else if (pEnd - p >= 4 && p[1] == CharT('N') && p[2] == CharT('A') else if (pEnd - p >= 4 && p[1] == CharT('N') && p[2] == CharT('A')
...@@ -897,7 +891,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ...@@ -897,7 +891,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
bSign = false; // don't negate again bSign = false; // don't negate again
} }
// Eat any further digits: // Eat any further digits:
while (p != pEnd && isDigit(*p)) while (p != pEnd && rtl::isAsciiDigit(*p))
++p; ++p;
} }
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "surrogates.hxx" #include "surrogates.hxx"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "rtl/character.hxx"
#include "rtl/strbuf.hxx" #include "rtl/strbuf.hxx"
#include "rtl/textenc.h" #include "rtl/textenc.h"
#include "rtl/textcvt.h" #include "rtl/textcvt.h"
...@@ -39,20 +40,6 @@ std::size_t const nCharClassSize = 128; ...@@ -39,20 +40,6 @@ std::size_t const nCharClassSize = 128;
sal_Unicode const cEscapePrefix = 0x25; // '%' sal_Unicode const cEscapePrefix = 0x25; // '%'
inline bool isDigit(sal_uInt32 nUtf32)
{
return nUtf32 >= 0x30 && nUtf32 <= 0x39; // '0'--'9'
}
inline bool isAlpha(sal_uInt32 nUtf32)
{
// 'A'--'Z', 'a'--'z'
return (
(nUtf32 >= 0x41 && nUtf32 <= 0x5A) ||
(nUtf32 >= 0x61 && nUtf32 <= 0x7A)
);
}
inline bool isHighSurrogate(sal_uInt32 nUtf16) inline bool isHighSurrogate(sal_uInt32 nUtf16)
{ {
return SAL_RTL_IS_HIGH_SURROGATE(nUtf16); return SAL_RTL_IS_HIGH_SURROGATE(nUtf16);
...@@ -376,7 +363,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents) ...@@ -376,7 +363,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents)
sal_Unicode const * pEnd = pBegin + pUriRef->length; sal_Unicode const * pEnd = pBegin + pUriRef->length;
sal_Unicode const * pPos = pBegin; sal_Unicode const * pPos = pBegin;
if (pPos != pEnd && isAlpha(*pPos)) if (pPos != pEnd && rtl::isAsciiAlpha(*pPos))
{ {
for (sal_Unicode const * p = pPos + 1; p != pEnd; ++p) for (sal_Unicode const * p = pPos + 1; p != pEnd; ++p)
{ {
...@@ -387,7 +374,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents) ...@@ -387,7 +374,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents)
pPos = p; pPos = p;
break; break;
} }
else if (!isAlpha(*p) && !isDigit(*p) && *p != '+' && *p != '-' else if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-'
&& *p != '.') && *p != '.')
{ {
break; break;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "cppuhelper/implbase2.hxx" #include "cppuhelper/implbase2.hxx"
#include "cppuhelper/weak.hxx" #include "cppuhelper/weak.hxx"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "rtl/character.hxx"
#include "rtl/string.h" #include "rtl/string.h"
#include "rtl/ustrbuf.hxx" #include "rtl/ustrbuf.hxx"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
...@@ -56,28 +57,8 @@ namespace { ...@@ -56,28 +57,8 @@ namespace {
//TODO: move comphelper::string::misc into something like //TODO: move comphelper::string::misc into something like
//sal/salhelper and use those instead //sal/salhelper and use those instead
bool isDigit(sal_Unicode c) {
return c >= '0' && c <= '9';
}
bool isUpperCase(sal_Unicode c) {
return c >= 'A' && c <= 'Z';
}
bool isLowerCase(sal_Unicode c) {
return c >= 'a' && c <= 'z';
}
bool isAlpha(sal_Unicode c) {
return isUpperCase(c) || isLowerCase(c);
}
bool isHexDigit(sal_Unicode c) {
return isDigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
}
sal_Unicode toLowerCase(sal_Unicode c) { sal_Unicode toLowerCase(sal_Unicode c) {
return isUpperCase(c) ? c + ('a' - 'A') : c; return rtl::isAsciiUpperCase(c) ? c + ('a' - 'A') : c;
} }
bool equalIgnoreCase(sal_Unicode c1, sal_Unicode c2) { bool equalIgnoreCase(sal_Unicode c1, sal_Unicode c2) {
...@@ -88,8 +69,8 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) { ...@@ -88,8 +69,8 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) {
if (s1.getLength() == s2.getLength()) { if (s1.getLength() == s2.getLength()) {
for (sal_Int32 i = 0; i < s1.getLength();) { for (sal_Int32 i = 0; i < s1.getLength();) {
if (s1[i] == '%' && s2[i] == '%' && s1.getLength() - i > 2 if (s1[i] == '%' && s2[i] == '%' && s1.getLength() - i > 2
&& isHexDigit(s1[i + 1]) && isHexDigit(s1[i + 2]) && rtl::isAsciiHexDigit(s1[i + 1]) && rtl::isAsciiHexDigit(s1[i + 2])
&& isHexDigit(s2[i + 1]) && isHexDigit(s2[i + 2]) && rtl::isAsciiHexDigit(s2[i + 1]) && rtl::isAsciiHexDigit(s2[i + 2])
&& equalIgnoreCase(s1[i + 1], s2[i + 1]) && equalIgnoreCase(s1[i + 1], s2[i + 1])
&& equalIgnoreCase(s1[i + 2], s2[i + 2])) && equalIgnoreCase(s1[i + 2], s2[i + 2]))
{ {
...@@ -107,12 +88,12 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) { ...@@ -107,12 +88,12 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) {
} }
sal_Int32 parseScheme(OUString const & uriReference) { sal_Int32 parseScheme(OUString const & uriReference) {
if (uriReference.getLength() >= 2 && isAlpha(uriReference[0])) { if (uriReference.getLength() >= 2 && rtl::isAsciiAlpha(uriReference[0])) {
for (sal_Int32 i = 0; i < uriReference.getLength(); ++i) { for (sal_Int32 i = 0; i < uriReference.getLength(); ++i) {
sal_Unicode c = uriReference[i]; sal_Unicode c = uriReference[i];
if (c == ':') { if (c == ':') {
return i; return i;
} else if (!isAlpha(c) && !isDigit(c) && c != '+' && c != '-' } else if (!rtl::isAsciiAlpha(c) && !rtl::isAsciiDigit(c) && c != '+' && c != '-'
&& c != '.') && c != '.')
{ {
break; break;
...@@ -381,7 +362,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse( ...@@ -381,7 +362,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
RTL_CONSTASCII_STRINGPARAM("com.sun.star.uri.UriSchemeParser_")); RTL_CONSTASCII_STRINGPARAM("com.sun.star.uri.UriSchemeParser_"));
for (sal_Int32 i = 0; i < scheme.getLength(); ++i) { for (sal_Int32 i = 0; i < scheme.getLength(); ++i) {
sal_Unicode c = scheme[i]; sal_Unicode c = scheme[i];
if (isUpperCase(c)) { if (rtl::isAsciiUpperCase(c)) {
buf.append(toLowerCase(c)); buf.append(toLowerCase(c));
} else if (c == '+') { } else if (c == '+') {
buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("PLUS")); buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("PLUS"));
...@@ -390,7 +371,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse( ...@@ -390,7 +371,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
} else if (c == '.') { } else if (c == '.') {
buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("DOT")); buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("DOT"));
} else { } else {
OSL_ASSERT(isLowerCase(c) || isDigit(c)); OSL_ASSERT(rtl::isAsciiLowerCase(c) || rtl::isAsciiDigit(c));
buf.append(c); buf.append(c);
} }
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "tools/toolsdllapi.h" #include "tools/toolsdllapi.h"
#include <rtl/alloc.h> #include <rtl/alloc.h>
#include <rtl/character.hxx>
#include <rtl/string.hxx> #include <rtl/string.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/tencinfo.h> #include <rtl/tencinfo.h>
...@@ -537,7 +538,7 @@ public: ...@@ -537,7 +538,7 @@ public:
// static // static
inline bool INetMIME::isUSASCII(sal_uInt32 nChar) inline bool INetMIME::isUSASCII(sal_uInt32 nChar)
{ {
return nChar <= 0x7F; return rtl::isAscii(nChar);
} }
// static // static
...@@ -567,74 +568,74 @@ inline bool INetMIME::isVisible(sal_uInt32 nChar) ...@@ -567,74 +568,74 @@ inline bool INetMIME::isVisible(sal_uInt32 nChar)
// static // static
inline bool INetMIME::isDigit(sal_uInt32 nChar) inline bool INetMIME::isDigit(sal_uInt32 nChar)
{ {
return nChar >= '0' && nChar <= '9'; return rtl::isAsciiDigit(nChar);
} }
// static // static
inline bool INetMIME::isCanonicHexDigit(sal_uInt32 nChar) inline bool INetMIME::isCanonicHexDigit(sal_uInt32 nChar)
{ {
return isDigit(nChar) || (nChar >= 'A' && nChar <= 'F'); return rtl::isAsciiCanonicHexDigit(nChar);
} }
// static // static
inline bool INetMIME::isHexDigit(sal_uInt32 nChar) inline bool INetMIME::isHexDigit(sal_uInt32 nChar)
{ {
return isCanonicHexDigit(nChar) || (nChar >= 'a' && nChar <= 'f'); return rtl::isAsciiHexDigit(nChar);
} }
// static // static
inline bool INetMIME::isUpperCase(sal_uInt32 nChar) inline bool INetMIME::isUpperCase(sal_uInt32 nChar)
{ {
return nChar >= 'A' && nChar <= 'Z'; return rtl::isAsciiUpperCase(nChar);
} }
// static // static
inline bool INetMIME::isLowerCase(sal_uInt32 nChar) inline bool INetMIME::isLowerCase(sal_uInt32 nChar)
{ {
return nChar >= 'a' && nChar <= 'z'; return rtl::isAsciiLowerCase(nChar);
} }
// static // static
inline bool INetMIME::isAlpha(sal_uInt32 nChar) inline bool INetMIME::isAlpha(sal_uInt32 nChar)
{ {
return isUpperCase(nChar) || isLowerCase(nChar); return rtl::isAsciiAlpha(nChar);
} }
// static // static
inline bool INetMIME::isAlphanumeric(sal_uInt32 nChar) inline bool INetMIME::isAlphanumeric(sal_uInt32 nChar)
{ {
return isAlpha(nChar) || isDigit(nChar); return rtl::isAsciiAlphanumeric(nChar);
} }
// static // static
inline bool INetMIME::isBase64Digit(sal_uInt32 nChar) inline bool INetMIME::isBase64Digit(sal_uInt32 nChar)
{ {
return isUpperCase(nChar) || isLowerCase(nChar) || isDigit(nChar) return rtl::isAsciiUpperCase(nChar) || rtl::isAsciiLowerCase(nChar) || rtl::isAsciiDigit(nChar)
|| nChar == '+' || nChar == '/'; || nChar == '+' || nChar == '/';
} }
// static // static
inline sal_uInt32 INetMIME::toUpperCase(sal_uInt32 nChar) inline sal_uInt32 INetMIME::toUpperCase(sal_uInt32 nChar)
{ {
return isLowerCase(nChar) ? nChar - ('a' - 'A') : nChar; return rtl::isAsciiLowerCase(nChar) ? nChar - ('a' - 'A') : nChar;
} }
// static // static
inline sal_uInt32 INetMIME::toLowerCase(sal_uInt32 nChar) inline sal_uInt32 INetMIME::toLowerCase(sal_uInt32 nChar)
{ {
return isUpperCase(nChar) ? nChar + ('a' - 'A') : nChar; return rtl::isAsciiUpperCase(nChar) ? nChar + ('a' - 'A') : nChar;
} }
// static // static
inline int INetMIME::getWeight(sal_uInt32 nChar) inline int INetMIME::getWeight(sal_uInt32 nChar)
{ {
return isDigit(nChar) ? int(nChar - '0') : -1; return rtl::isAsciiDigit(nChar) ? int(nChar - '0') : -1;
} }
// static // static
inline int INetMIME::getHexWeight(sal_uInt32 nChar) inline int INetMIME::getHexWeight(sal_uInt32 nChar)
{ {
return isDigit(nChar) ? int(nChar - '0') : return rtl::isAsciiDigit(nChar) ? int(nChar - '0') :
nChar >= 'A' && nChar <= 'F' ? int(nChar - 'A' + 10) : nChar >= 'A' && nChar <= 'F' ? int(nChar - 'A' + 10) :
nChar >= 'a' && nChar <= 'f' ? int(nChar - 'a' + 10) : -1; nChar >= 'a' && nChar <= 'f' ? int(nChar - 'a' + 10) : -1;
} }
...@@ -642,9 +643,9 @@ inline int INetMIME::getHexWeight(sal_uInt32 nChar) ...@@ -642,9 +643,9 @@ inline int INetMIME::getHexWeight(sal_uInt32 nChar)
// static // static
inline int INetMIME::getBase64Weight(sal_uInt32 nChar) inline int INetMIME::getBase64Weight(sal_uInt32 nChar)
{ {
return isUpperCase(nChar) ? int(nChar - 'A') : return rtl::isAsciiUpperCase(nChar) ? int(nChar - 'A') :
isLowerCase(nChar) ? int(nChar - 'a' + 26) : rtl::isAsciiLowerCase(nChar) ? int(nChar - 'a' + 26) :
isDigit(nChar) ? int(nChar - '0' + 52) : rtl::isAsciiDigit(nChar) ? int(nChar - '0' + 52) :
nChar == '+' ? 62 : nChar == '+' ? 62 :
nChar == '/' ? 63 : nChar == '/' ? 63 :
nChar == '=' ? -1 : -2; nChar == '=' ? -1 : -2;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment