wxStringOperationsWchar::Utf16CharBuffer wxStringOperationsWchar::EncodeChar(const wxUniChar& ch) { Utf16CharBuffer buf; if ( ch.IsSupplementary() ) { buf.data[0] = (wchar_t)ch.HighSurrogate(); buf.data[1] = (wchar_t)ch.LowSurrogate(); buf.data[2] = L'\0'; } else { // Assume ch is a BMP character buf.data[0] = (wchar_t)ch; buf.data[1] = L'\0'; } return buf; }
int wxToupper_l(const wxUniChar& c, const wxXLocale& loc) { wxCHECK(loc.IsOk(), false); if(CTYPE_TEST(c.GetValue(), CTYPE_LOWER)) { return c - 'a' + 'A'; } return c; }
wxWCharBuffer wxStringOperationsWchar::EncodeNChars(size_t n, const wxUniChar& ch) { if ( ch.IsSupplementary() ) { wxWCharBuffer buf(n * 2); wchar_t s[2] = { (wchar_t)ch.HighSurrogate(), (wchar_t)ch.LowSurrogate(), }; wchar_t *ptr = buf.data(); for (size_t i = 0; i < n; i++, ptr += 2) { wmemcpy(ptr, s, 2); } return buf; } else { // Assume ch is a BMP character wxWCharBuffer buf(n); wmemset(buf.data(), (wchar_t)ch, n); return buf; } }
bool IsWhitespace(wxUniChar c) { return !!u_isUWhiteSpace(c.GetValue()); }