diff options
author | Arnaud Versini <arnaud.versini@libreoffice.org> | 2013-09-07 17:11:44 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-09-30 11:49:22 +0200 |
commit | 89de6ba4c65c8709e32fe636ff743d914cf56225 (patch) | |
tree | e74c324223f4a8e9550fe778893a7e98a82490c7 /include/rtl | |
parent | c1df0ce01b441ffa3e6238d93e49532620a1fc93 (diff) |
Introduce ASCII case conversion and use more/rtl/character.hxx.
Also remove all others implementations.
Change-Id: I1dc108a9103f087bd8ce591dff2ac5dd254746f8
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl')
-rw-r--r-- | include/rtl/character.hxx | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx index 01350e19ee78..2218158e7ac7 100644 --- a/include/rtl/character.hxx +++ b/include/rtl/character.hxx @@ -139,6 +139,40 @@ inline bool isAsciiHexDigit(sal_uInt32 nUtf32) return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f'); } +/** Convert a character, if ASCII, to upper case. + + @param nChar A Unicode scalar value (represented as a UTF-32 code unit). + + @return + nChar converted to ASCII upper case + + @since LibreOffice 4.2 +*/ +inline sal_uInt32 toAsciiUpperCase(sal_uInt32 nChar) +{ + if( isAsciiLowerCase(nChar) ) + nChar -= 32; + + return nChar; +} + +/** Convert a character, if ASCII, to lower case. + + @param nChar A Unicode scalar value (represented as a UTF-32 code unit). + + @return + nChar converted to ASCII lower case + + @since LibreOffice 4.2 +*/ +inline sal_uInt32 toAsciiLowerCase(sal_uInt32 nChar) +{ + if( isAsciiUpperCase(nChar) ) + nChar += 32; + + return nChar; +} + /** Compare two US-ASCII characters. @param nChar1 A Unicode scalar value (represented as a UTF-32 code unit). @@ -146,21 +180,18 @@ inline bool isAsciiHexDigit(sal_uInt32 nUtf32) @return 0 if both strings are equal - < 0 - if this string is less than the string argument - > 0 - if this string is greater than the string argument + < 0 - if this nChar1 is less than nChar2 argument + > 0 - if this nChar1 is greater than the nChar2 argument @since LibreOffice 4.2 */ inline sal_Int32 compareAsciiIgnoreCase(sal_uInt32 nChar1, sal_uInt32 nChar2) { - assert(isAscii(nChar1) && isAscii(nChar2)); - if ( isAsciiUpperCase(nChar1) ) - nChar1 += 32; - if ( isAsciiUpperCase(nChar2) ) - nChar2 += 32; - return nChar1 - nChar2; -} + nChar1 = toAsciiLowerCase(nChar1); + nChar2 = toAsciiLowerCase(nChar2); + return ((sal_Int32) nChar1) - ((sal_Int32) nChar2); +} }//rtl namespace |