git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46376
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
- // buffer for single UTF-8 character
- struct Utf8CharBuffer
- {
- char data[5];
- operator const char*() const { return data; }
- };
-
// encodes the character as UTF-8:
// encodes the character as UTF-8:
- static Utf8CharBuffer EncodeChar(const wxUniChar& ch);
+ typedef wxUniChar::Utf8CharBuffer Utf8CharBuffer;
+ static Utf8CharBuffer EncodeChar(const wxUniChar& ch)
+ { return ch.AsUTF8(); }
// returns n copies of ch encoded in UTF-8 string
static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch);
// returns n copies of ch encoded in UTF-8 string
static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch);
// Returns Unicode code point value of the character
value_type GetValue() const { return m_value; }
// Returns Unicode code point value of the character
value_type GetValue() const { return m_value; }
+#if wxUSE_UNICODE_UTF8
+ // buffer for single UTF-8 character
+ struct Utf8CharBuffer
+ {
+ char data[5];
+ operator const char*() const { return data; }
+ };
+
+ // returns the character encoded as UTF-8
+ // (NB: implemented in stringops.cpp)
+ Utf8CharBuffer AsUTF8() const;
+#endif // wxUSE_UNICODE_UTF8
+
// Returns true if the character is an ASCII character:
bool IsAscii() const { return m_value < 0x80; }
// Returns true if the character is an ASCII character:
bool IsAscii() const { return m_value < 0x80; }
#endif
wxUniChar::value_type GetValue() const { return UniChar().GetValue(); }
#endif
wxUniChar::value_type GetValue() const { return UniChar().GetValue(); }
+
+#if wxUSE_UNICODE_UTF8
+ wxUniChar::Utf8CharBuffer AsUTF8() const { return UniChar().AsUTF8(); }
+#endif // wxUSE_UNICODE_UTF8
+
bool IsAscii() const { return UniChar().IsAscii(); }
// Assignment operators:
bool IsAscii() const { return UniChar().IsAscii(); }
// Assignment operators:
-wxStringOperationsUtf8::Utf8CharBuffer
-wxStringOperationsUtf8::EncodeChar(const wxUniChar& ch)
+// NB: this is in this file and not unichar.cpp to keep all UTF-8 encoding
+// code in single place
+wxUniChar::Utf8CharBuffer wxUniChar::AsUTF8() const
{
Utf8CharBuffer buf;
char *out = buf.data;
{
Utf8CharBuffer buf;
char *out = buf.data;
- wxUniChar::value_type code = ch.GetValue();
+ value_type code = GetValue();
// Char. number range | UTF-8 octet sequence
// (hexadecimal) | (binary)
// Char. number range | UTF-8 octet sequence
// (hexadecimal) | (binary)