Add some functions to handle supplementary characters
The added functions are: - wxUniChar::IsBMP() - wxUniChar::IsSupplementary() - wxUniChar::HighSurrogate() - wxUniChar::LowSurrogate()
This commit is contained in:
@@ -83,6 +83,38 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if the character is a BMP character:
|
||||||
|
static bool IsBMP(wxUint32 value) { return value < 0x10000; }
|
||||||
|
|
||||||
|
// Returns true if the character is a supplementary character:
|
||||||
|
static bool IsSupplementary(wxUint32 value) { return 0x10000 <= value && value < 0x110000; }
|
||||||
|
|
||||||
|
// Returns the high surrogate code unit for the supplementary character
|
||||||
|
static wxUint16 HighSurrogate(wxUint32 value)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(IsSupplementary(value), "wxUniChar::HighSurrogate() must be called on a supplementary character");
|
||||||
|
return 0xD800 | ((value - 0x10000) >> 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the low surrogate code unit for the supplementary character
|
||||||
|
static wxUint16 LowSurrogate(wxUint32 value)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(IsSupplementary(value), "wxUniChar::LowSurrogate() must be called on a supplementary character");
|
||||||
|
return 0xDC00 | ((value - 0x10000) & 0x03FF);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the character is a BMP character:
|
||||||
|
bool IsBMP() const { return IsBMP(m_value); }
|
||||||
|
|
||||||
|
// Returns true if the character is a supplementary character:
|
||||||
|
bool IsSupplementary() const { return IsSupplementary(m_value); }
|
||||||
|
|
||||||
|
// Returns the high surrogate code unit for the supplementary character
|
||||||
|
wxUint16 HighSurrogate() const { return HighSurrogate(m_value); }
|
||||||
|
|
||||||
|
// Returns the low surrogate code unit for the supplementary character
|
||||||
|
wxUint16 LowSurrogate() const { return LowSurrogate(m_value); }
|
||||||
|
|
||||||
// Conversions to char and wchar_t types: all of those are needed to be
|
// Conversions to char and wchar_t types: all of those are needed to be
|
||||||
// able to pass wxUniChars to verious standard narrow and wide character
|
// able to pass wxUniChars to verious standard narrow and wide character
|
||||||
// functions
|
// functions
|
||||||
@@ -216,6 +248,11 @@ public:
|
|||||||
bool IsAscii() const { return UniChar().IsAscii(); }
|
bool IsAscii() const { return UniChar().IsAscii(); }
|
||||||
bool GetAsChar(char *c) const { return UniChar().GetAsChar(c); }
|
bool GetAsChar(char *c) const { return UniChar().GetAsChar(c); }
|
||||||
|
|
||||||
|
bool IsBMP() const { return UniChar().IsBMP(); }
|
||||||
|
bool IsSupplementary() const { return UniChar().IsSupplementary(); }
|
||||||
|
wxUint16 HighSurrogate() const { return UniChar().HighSurrogate(); }
|
||||||
|
wxUint16 LowSurrogate() const { return UniChar().LowSurrogate(); }
|
||||||
|
|
||||||
// Assignment operators:
|
// Assignment operators:
|
||||||
#if wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE_UTF8
|
||||||
wxUniCharRef& operator=(const wxUniChar& c);
|
wxUniCharRef& operator=(const wxUniChar& c);
|
||||||
|
@@ -83,6 +83,82 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool GetAsChar(char *c) const;
|
bool GetAsChar(char *c) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns true if the character is a BMP character (i.e.\ if its value is less than 0x10000).
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
bool IsBMP() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns true if the character is a BMP character (i.e.\ if its value is less than 0x10000).
|
||||||
|
|
||||||
|
@param value
|
||||||
|
The Unicode code point of the character.
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
static bool IsBMP(wxUint32 value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns true if the character is a supplementary character (i.e.\ between 0x10000 and 0x10FFFF).
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
bool IsSupplementary() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns true if the character is a supplementary character (i.e.\ between 0x10000 and 0x10FFFF).
|
||||||
|
|
||||||
|
@param value
|
||||||
|
The Unicode code point of the character.
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
static bool IsSupplementary(wxUint32 value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the high surrogate code unit for the supplementary character.
|
||||||
|
|
||||||
|
@pre IsSupplementary() const
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
wxUint16 HighSurrogate() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the high surrogate code unit for the supplementary character.
|
||||||
|
|
||||||
|
@param value
|
||||||
|
The Unicode code point of the character.
|
||||||
|
|
||||||
|
@pre IsSupplementary(wxUint32 value)
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
static wxUint16 HighSurrogate(wxUint32 value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the low surrogate code unit for the supplementary character.
|
||||||
|
|
||||||
|
@pre IsSupplementary() const
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
wxUint16 LowSurrogate() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the low surrogate code unit for the supplementary character.
|
||||||
|
|
||||||
|
@param value
|
||||||
|
The Unicode code point of the character.
|
||||||
|
|
||||||
|
@pre IsSupplementary(wxUint32 value)
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
static wxUint16 LowSurrogate(wxUint32 value);
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/**
|
/**
|
||||||
Conversions to char and wchar_t types: all of those are needed to be
|
Conversions to char and wchar_t types: all of those are needed to be
|
||||||
|
Reference in New Issue
Block a user