37 using CharType = char;
40 : data (const_cast<CharType*> (rawPointer))
54 data =
const_cast<CharType*
> (text);
60 inline bool operator!= (
CharPointer_UTF8 other)
const noexcept {
return data != other.data; }
61 inline bool operator<= (
CharPointer_UTF8 other)
const noexcept {
return data <= other.data; }
62 inline bool operator< (
CharPointer_UTF8 other)
const noexcept {
return data < other.data; }
63 inline bool operator>= (
CharPointer_UTF8 other)
const noexcept {
return data >= other.data; }
64 inline bool operator> (
CharPointer_UTF8 other)
const noexcept {
return data > other.data; }
67 inline CharType*
getAddress() const noexcept {
return data; }
70 inline operator const CharType*()
const noexcept {
return data; }
73 inline bool isEmpty() const noexcept {
return *data == 0; }
76 inline bool isNotEmpty() const noexcept {
return *data != 0; }
81 auto byte = (
signed char) *data;
84 return (juce_wchar) (uint8) byte;
86 uint32 n = (uint32) (uint8) byte;
89 int numExtraValues = 0;
91 while ((n & bit) != 0 && bit > 0x8)
100 for (
int i = 1; i <= numExtraValues; ++i)
102 auto nextByte = (uint32) (uint8) data[i];
104 if ((nextByte & 0xc0) != 0x80)
108 n |= (nextByte & 0x3f);
111 return (juce_wchar) n;
117 jassert (*data != 0);
118 auto n = (
signed char) *data++;
124 while ((static_cast<uint8> (n) & bit) != 0 && bit > 0x8)
139 while ((*--data & 0xc0) == 0x80 && ++count < 4)
149 auto byte = (
signed char) *data++;
152 return (juce_wchar) (uint8) byte;
154 uint32 n = (uint32) (uint8) byte;
157 int numExtraValues = 0;
159 while ((n & bit) != 0 && bit > 0x8)
168 while (--numExtraValues >= 0)
170 auto nextByte = (uint32) (uint8) *data;
172 if ((nextByte & 0xc0) != 0x80)
177 n |= (nextByte & 0x3f);
180 return (juce_wchar) n;
196 while (++numToSkip <= 0)
201 while (--numToSkip >= 0)
244 auto n = (uint32) (uint8) *d++;
248 while ((*d & 0xc0) == 0x80)
261 size_t lengthUpTo (
const size_t maxCharsToCount)
const noexcept
277 jassert (data !=
nullptr);
278 return strlen (data) + 1;
287 auto c = (uint32) charToWrite;
307 template <
class CharPo
inter>
312 while (
auto n = text.getAndAdvance())
325 void write (
const juce_wchar charToWrite) noexcept
327 auto c = (uint32) charToWrite;
331 int numExtraBytes = 1;
339 *data++ = (CharType) ((uint32) (0xff << (7 - numExtraBytes)) | (c >> (numExtraBytes * 6)));
341 while (--numExtraBytes >= 0)
342 *data++ = (CharType) (0x80 | (0x3f & (c >> (numExtraBytes * 6))));
346 *data++ = (CharType) c;
357 template <
typename CharPo
inter>
368 while ((*data = *s) != 0)
379 template <
typename CharPo
inter>
389 template <
typename CharPo
inter>
396 template <
typename CharPo
inter>
397 int compare (
const CharPointer other)
const noexcept
403 template <
typename CharPo
inter>
404 int compareUpTo (
const CharPointer other,
const int maxChars)
const noexcept
410 template <
typename CharPo
inter>
423 template <
typename CharPo
inter>
430 template <
typename CharPo
inter>
431 int indexOf (
const CharPointer stringToFind)
const noexcept
437 int indexOf (
const juce_wchar charToFind)
const noexcept
443 int indexOf (
const juce_wchar charToFind,
const bool ignoreCase)
const noexcept
450 bool isWhitespace() const noexcept {
const CharType c = *data;
return c ==
' ' || (c <= 13 && c >= 9); }
452 bool isDigit() const noexcept {
const CharType c = *data;
return c >=
'0' && c <=
'9'; }
473 #if JUCE_WINDOWS && ! JUCE_MINGW 474 return _atoi64 (data);
489 return ((uint32) character) < (uint32) 0x10ffff;
495 while (--maxBytesToRead >= 0 && *dataToTest != 0)
497 auto byte = (
signed char) *dataToTest++;
502 int numExtraValues = 0;
504 while ((byte & bit) != 0)
512 if (bit == 8 && (numExtraValues > maxBytesToRead
517 if (numExtraValues == 0)
520 maxBytesToRead -= numExtraValues;
521 if (maxBytesToRead < 0)
524 while (--numExtraValues >= 0)
525 if ((*dataToTest++ & 0xc0) != 0x80)
542 byteOrderMark1 = 0xef,
543 byteOrderMark2 = 0xbb,
544 byteOrderMark3 = 0xbf
552 jassert (possibleByteOrder !=
nullptr);
553 auto c =
static_cast<const uint8*
> (possibleByteOrder);
555 return c[0] == (uint8) byteOrderMark1
556 && c[1] == (uint8) byteOrderMark2
557 && c[2] == (uint8) byteOrderMark3;
static size_t getBytesRequiredFor(const juce_wchar charToWrite) noexcept
bool isLetter() const noexcept
juce_wchar toUpperCase() const noexcept
int indexOf(const juce_wchar charToFind) const noexcept
static double getDoubleValue(CharPointerType text) noexcept
static juce_wchar toUpperCase(juce_wchar character) noexcept
void writeWithCharLimit(const CharPointer src, const int maxChars) noexcept
bool isLetterOrDigit() const noexcept
bool isDigit() const noexcept
CharPointer_UTF8 & operator++() noexcept
size_t length() const noexcept
size_t lengthUpTo(const CharPointer_UTF8 end) const noexcept
int compareIgnoreCase(const CharPointer_UTF8 other) const noexcept
double getDoubleValue() const noexcept
static int indexOfCharIgnoreCase(Type text, juce_wchar charToFind) noexcept
static void copyAll(DestCharPointerType &dest, SrcCharPointerType src) noexcept
juce_wchar operator*() const noexcept
bool isLowerCase() const noexcept
static int compareIgnoreCase(juce_wchar char1, juce_wchar char2) noexcept
void operator-=(int numToSkip) noexcept
bool isNotEmpty() const noexcept
bool isEmpty() const noexcept
static Type findEndOfWhitespace(Type text) noexcept
size_t lengthUpTo(const size_t maxCharsToCount) const noexcept
size_t writeWithDestByteLimit(const CharPointer src, const size_t maxDestBytes) noexcept
static bool isValidString(const CharType *dataToTest, int maxBytesToRead)
CharPointer_UTF8 operator--() noexcept
CharPointer_UTF8 findEndOfWhitespace() const noexcept
CharPointer_UTF8 operator+(int numToSkip) const noexcept
static int indexOfChar(Type text, const juce_wchar charToFind) noexcept
void writeAll(const CharPointer src) noexcept
bool isWhitespace() const noexcept
static int compareIgnoreCaseUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
juce_wchar toLowerCase() const noexcept
int indexOf(const CharPointer stringToFind) const noexcept
static bool isUpperCase(juce_wchar character) noexcept
static size_t lengthUpTo(CharPointerType text, const size_t maxCharsToCount) noexcept
static size_t getBytesRequiredFor(CharPointer text) noexcept
bool operator==(CharPointer_UTF8 other) const noexcept
static size_t copyWithDestByteLimit(DestCharPointerType &dest, SrcCharPointerType src, size_t maxBytesToWrite) noexcept
bool isUpperCase() const noexcept
juce_wchar getAndAdvance() noexcept
CharType * getAddress() const noexcept
int compareIgnoreCase(const CharPointer other) const noexcept
CharPointer_UTF8 findTerminatingNull() const noexcept
int compareUpTo(const CharPointer other, const int maxChars) const noexcept
static juce_wchar toLowerCase(juce_wchar character) noexcept
int64 getIntValue64() const noexcept
static bool isByteOrderMark(const void *possibleByteOrder) noexcept
static bool isLetter(char character) noexcept
static bool canRepresent(juce_wchar character) noexcept
CharPointer_UTF8 atomicSwap(const CharPointer_UTF8 newValue)
void operator+=(int numToSkip) noexcept
CharPointer_UTF8 operator-(int numToSkip) const noexcept
int compareIgnoreCaseUpTo(const CharPointer other, const int maxChars) const noexcept
static int indexOf(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
int compare(const CharPointer other) const noexcept
void writeNull() const noexcept
int indexOf(const juce_wchar charToFind, const bool ignoreCase) const noexcept
int getIntValue32() const noexcept
static bool isLowerCase(juce_wchar character) noexcept
static bool isLetterOrDigit(char character) noexcept
static int compareUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
static void copyWithCharLimit(DestCharPointerType &dest, SrcCharPointerType src, int maxChars) noexcept
void writeAll(const CharPointer_UTF8 src) noexcept
static int compare(juce_wchar char1, juce_wchar char2) noexcept
size_t sizeInBytes() const noexcept
juce_wchar operator[](int characterIndex) const noexcept
void write(const juce_wchar charToWrite) noexcept