summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-07-24 20:52:44 +0300
committerخالد حسني <khaled@libreoffice.org>2023-07-25 02:14:56 +0200
commit2e6e40b7453e2005d46ba7866feff2f2caa1f100 (patch)
tree37b84a12a9660b94930eeb267072f6d34f8b9adb
parent89229524298398ca1b5239c2a7ca798900733f5d (diff)
i18nutil: Make unicode::getUnicodeType() take a UTF-32 code point
Still need to fix call sites to handles surrogate pairs. Change-Id: I3ba896714fc6a90596c041148a3c9d965f60f4a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154874 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
-rw-r--r--i18nutil/source/utility/unicode.cxx12
-rw-r--r--include/i18nutil/unicode.hxx10
2 files changed, 12 insertions, 10 deletions
diff --git a/i18nutil/source/utility/unicode.cxx b/i18nutil/source/utility/unicode.cxx
index dbb81a8240f1..ae7b4c512aca 100644
--- a/i18nutil/source/utility/unicode.cxx
+++ b/i18nutil/source/utility/unicode.cxx
@@ -67,9 +67,10 @@ unicode::getUnicodeScriptEnd( UnicodeScript type) {
}
sal_Int16
-unicode::getUnicodeType( const sal_Unicode ch ) {
- static sal_Unicode c = 0x00;
- static sal_Int16 r = 0x00;
+unicode::getUnicodeType(const sal_uInt32 ch)
+{
+ static sal_uInt32 c = 0x00;
+ static sal_uInt32 r = 0x00;
if (ch == c) return r;
else c = ch;
@@ -213,7 +214,7 @@ sal_uInt32 unicode::GetMirroredChar(sal_uInt32 nChar) {
bit(UnicodeType::PARAGRAPH_SEPARATOR)
#define IsType(func, mask) \
-bool func( const sal_Unicode ch) {\
+bool func( const sal_uInt32 ch) {\
return (bit(getUnicodeType(ch)) & (mask)) != 0;\
}
@@ -224,7 +225,8 @@ IsType(unicode::isSpace, SPACEMASK)
#define CONTROLSPACE bit(0x09)|bit(0x0a)|bit(0x0b)|bit(0x0c)|bit(0x0d)|\
bit(0x1c)|bit(0x1d)|bit(0x1e)|bit(0x1f)
-bool unicode::isWhiteSpace( const sal_Unicode ch) {
+bool unicode::isWhiteSpace(const sal_uInt32 ch)
+{
return (ch != 0xa0 && isSpace(ch)) || (ch <= 0x1F && (bit(ch) & (CONTROLSPACE)));
}
diff --git a/include/i18nutil/unicode.hxx b/include/i18nutil/unicode.hxx
index 69e3e9d6e267..be08595e0b10 100644
--- a/include/i18nutil/unicode.hxx
+++ b/include/i18nutil/unicode.hxx
@@ -38,17 +38,17 @@ struct ScriptTypeList
class I18NUTIL_DLLPUBLIC unicode
{
public:
- static sal_Int16 getUnicodeType(const sal_Unicode ch);
+ static sal_Int16 getUnicodeType(const sal_uInt32 ch);
static sal_Int16 getUnicodeScriptType(const sal_Unicode ch, const ScriptTypeList* typeList,
sal_Int16 unknownType = 0);
static sal_Unicode getUnicodeScriptStart(css::i18n::UnicodeScript type);
static sal_Unicode getUnicodeScriptEnd(css::i18n::UnicodeScript type);
static sal_uInt8 getUnicodeDirection(const sal_Unicode ch);
static sal_uInt32 GetMirroredChar(sal_uInt32);
- static bool isControl(const sal_Unicode ch);
- static bool isAlpha(const sal_Unicode ch);
- static bool isSpace(const sal_Unicode ch);
- static bool isWhiteSpace(const sal_Unicode ch);
+ static bool isControl(const sal_uInt32 ch);
+ static bool isAlpha(const sal_uInt32 ch);
+ static bool isSpace(const sal_uInt32 ch);
+ static bool isWhiteSpace(const sal_uInt32 ch);
/** Check for Unicode variation sequence selectors