summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-02-01 13:24:47 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-02-02 15:57:18 +0200
commita14bcdfcc9ce98a50ec4c9c7b253f976dbdfd849 (patch)
treefc2c355818ea31ef55defc83931b77d4b63fca41
parent4bfdf6a3d156184579e9fc66224754a6e66159dd (diff)
QtMiscUtils: replace uint args with char32_t
Also change isAsciiDigit() to take a char32_t, so that something like this works: QChar ch; isAsciiDigit(ch.unicode()) casting char16_t to uchar is narrowing, and gives weird results. C.f. QSettingsPrivate::iniEscapedKey() and the QSettings unittests which uses some unicode characters. Task-number: QTBUG-110403 Change-Id: Id978a6b2874bc6869ae3ffb28d1887d932c37782 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/tools/qtools_p.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index b0fc13bbba..3ffa553843 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -21,17 +21,17 @@
QT_BEGIN_NAMESPACE
namespace QtMiscUtils {
-constexpr inline char toHexUpper(uint value) noexcept
+constexpr inline char toHexUpper(char32_t value) noexcept
{
return "0123456789ABCDEF"[value & 0xF];
}
-constexpr inline char toHexLower(uint value) noexcept
+constexpr inline char toHexLower(char32_t value) noexcept
{
return "0123456789abcdef"[value & 0xF];
}
-constexpr inline int fromHex(uint c) noexcept
+constexpr inline int fromHex(char32_t c) noexcept
{
return ((c >= '0') && (c <= '9')) ? int(c - '0') :
((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) :
@@ -39,17 +39,17 @@ constexpr inline int fromHex(uint c) noexcept
/* otherwise */ -1;
}
-constexpr inline char toOct(uint value) noexcept
+constexpr inline char toOct(char32_t value) noexcept
{
return char('0' + (value & 0x7));
}
-constexpr inline int fromOct(uint c) noexcept
+constexpr inline int fromOct(char32_t c) noexcept
{
return ((c >= '0') && (c <= '7')) ? int(c - '0') : -1;
}
-[[nodiscard]] constexpr inline bool isAsciiDigit(uchar c) noexcept
+[[nodiscard]] constexpr inline bool isAsciiDigit(char32_t c) noexcept
{
return c >= '0' && c <= '9';
}