Go to the documentation of this file.
29 #ifndef JUCE_CHARPOINTER_UTF8_H_INCLUDED
30 #define JUCE_CHARPOINTER_UTF8_H_INCLUDED
44 : data (
const_cast <CharType*
> (rawPointer))
61 data =
const_cast <CharType*
> (text);
85 const signed char byte = (
signed char) *data;
93 size_t numExtraValues = 0;
95 while ((n & bit) != 0 && bit > 0x10)
104 for (
size_t i = 1; i <= numExtraValues; ++i)
108 if ((nextByte & 0xc0) != 0x80)
112 n |= (nextByte & 0x3f);
122 const signed char n = (
signed char) *data++;
128 while ((n & bit) != 0 && bit > 0x8)
143 while ((*--data & 0xc0) == 0x80 && ++count < 4)
153 const signed char byte = (
signed char) *data++;
161 int numExtraValues = 0;
163 while ((n & bit) != 0 && bit > 0x8)
172 while (--numExtraValues >= 0)
176 if ((nextByte & 0xc0) != 0x80)
181 n |= (nextByte & 0x3f);
200 while (++numToSkip <= 0)
205 while (--numToSkip >= 0)
252 while ((*d & 0xc0) == 0x80)
282 return strlen (data) + 1;
311 template <
class CharPo
inter>
317 while ((n = text.getAndAdvance()) != 0)
336 int numExtraBytes = 1;
344 *data++ = (
CharType) ((
uint32) (0xff << (7 - numExtraBytes)) | (c >> (numExtraBytes * 6)));
346 while (--numExtraBytes >= 0)
347 *data++ = (
CharType) (0x80 | (0x3f & (c >> (numExtraBytes * 6))));
362 template <
typename CharPo
inter>
373 while ((*data = *s) != 0)
384 template <
typename CharPo
inter>
394 template <
typename CharPo
inter>
401 template <
typename CharPo
inter>
408 template <
typename CharPo
inter>
415 template <
typename CharPo
inter>
425 return stricmp (data, other.data);
429 return strcasecmp (data, other.data);
434 template <
typename CharPo
inter>
441 template <
typename CharPo
inter>
484 #if JUCE_LINUX || JUCE_ANDROID || JUCE_MINGW
487 return _atoi64 (data);
489 return CharacterFunctions::getIntValue <int64, CharPointer_UTF8> (*
this);
502 return ((
unsigned int) character) < (
unsigned int) 0x10ffff;
508 while (--maxBytesToRead >= 0 && *dataToTest != 0)
510 const signed char byte = (
signed char) *dataToTest++;
515 int numExtraValues = 0;
517 while ((
byte & bit) != 0)
525 if (bit == 8 && (numExtraValues > maxBytesToRead
530 maxBytesToRead -= numExtraValues;
531 if (maxBytesToRead < 0)
534 while (--numExtraValues >= 0)
535 if ((*dataToTest++ & 0xc0) != 0x80)
562 jassert (possibleByteOrder !=
nullptr);
563 const uint8*
const c =
static_cast<const uint8*
> (possibleByteOrder);
574 #endif // JUCE_CHARPOINTER_UTF8_H_INCLUDED
juce_wchar getAndAdvance() noexcept
Definition: juce_CharPointer_UTF8.h:151
static bool isByteOrderMark(const void *possibleByteOrder) noexcept
Definition: juce_CharPointer_UTF8.h:560
static int compareIgnoreCase(CharPointerType1 s1, CharPointerType2 s2) noexcept
Definition: juce_CharacterFunctions.h:427
size_t length() const noexcept
Definition: juce_CharPointer_UTF8.h:241
bool operator<(CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:69
CharPointer_UTF8(const CharPointer_UTF8 &other) noexcept
Definition: juce_CharPointer_UTF8.h:48
static size_t getBytesRequiredFor(CharPointer text) noexcept
Definition: juce_CharPointer_UTF8.h:312
@ byteOrderMark3
Definition: juce_CharPointer_UTF8.h:554
unsigned int uint32
Definition: juce_MathsFunctions.h:51
void operator+=(int numToSkip) noexcept
Definition: juce_CharPointer_UTF8.h:196
int getIntValue32() const noexcept
Definition: juce_CharPointer_UTF8.h:479
juce_wchar operator[](int characterIndex) const noexcept
Definition: juce_CharPointer_UTF8.h:217
int compareIgnoreCase(const CharPointer other) const noexcept
Definition: juce_CharPointer_UTF8.h:416
CharPointer_UTF8(const CharType *const rawPointer) noexcept
Definition: juce_CharPointer_UTF8.h:43
static int indexOfChar(Type text, const juce_wchar charToFind) noexcept
Definition: juce_CharacterFunctions.h:544
static int compareUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
Definition: juce_CharacterFunctions.h:410
@ byteOrderMark2
Definition: juce_CharPointer_UTF8.h:553
bool isLowerCase() const noexcept
Definition: juce_CharPointer_UTF8.h:471
char CharType
Definition: juce_CharPointer_UTF8.h:41
size_t sizeInBytes() const noexcept
Definition: juce_CharPointer_UTF8.h:279
bool isEmpty() const noexcept
Definition: juce_CharPointer_UTF8.h:80
static bool canRepresent(juce_wchar character) noexcept
Definition: juce_CharPointer_UTF8.h:500
static bool isLowerCase(juce_wchar character) noexcept
Definition: juce_CharacterFunctions.cpp:54
int compareUpTo(const CharPointer other, const int maxChars) const noexcept
Definition: juce_CharPointer_UTF8.h:409
CharPointer_UTF8 findEndOfWhitespace() const noexcept
Definition: juce_CharPointer_UTF8.h:497
static double getDoubleValue(CharPointerType text) noexcept
Definition: juce_CharacterFunctions.h:253
static bool isUpperCase(juce_wchar character) noexcept
Definition: juce_CharacterFunctions.cpp:45
size_t lengthUpTo(const CharPointer_UTF8 end) const noexcept
Definition: juce_CharPointer_UTF8.h:271
void writeWithCharLimit(const CharPointer src, const int maxChars) noexcept
Definition: juce_CharPointer_UTF8.h:395
#define noexcept
Definition: juce_CompilerSupport.h:141
bool isUpperCase() const noexcept
Definition: juce_CharPointer_UTF8.h:469
int indexOf(const CharPointer stringToFind) const noexcept
Definition: juce_CharPointer_UTF8.h:442
bool isDigit() const noexcept
Definition: juce_CharPointer_UTF8.h:463
static size_t copyWithDestByteLimit(DestCharPointerType &dest, SrcCharPointerType src, size_t maxBytesToWrite) noexcept
Definition: juce_CharacterFunctions.h:350
void write(const juce_wchar charToWrite) noexcept
Definition: juce_CharPointer_UTF8.h:330
static size_t lengthUpTo(CharPointerType text, const size_t maxCharsToCount) noexcept
Definition: juce_CharacterFunctions.h:307
static void copyAll(DestCharPointerType &dest, SrcCharPointerType src) noexcept
Definition: juce_CharacterFunctions.h:332
size_t writeWithDestByteLimit(const CharPointer src, const size_t maxDestBytes) noexcept
Definition: juce_CharPointer_UTF8.h:385
unsigned char uint8
Definition: juce_MathsFunctions.h:43
int64 getIntValue64() const noexcept
Definition: juce_CharPointer_UTF8.h:482
bool isLetter() const noexcept
Definition: juce_CharPointer_UTF8.h:465
juce_wchar toLowerCase() const noexcept
Definition: juce_CharPointer_UTF8.h:476
bool operator==(CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:66
@ byteOrderMark1
Definition: juce_CharPointer_UTF8.h:552
juce_wchar toUpperCase() const noexcept
Definition: juce_CharPointer_UTF8.h:474
int compareIgnoreCaseUpTo(const CharPointer other, const int maxChars) const noexcept
Definition: juce_CharPointer_UTF8.h:435
void writeAll(const CharPointer_UTF8 src) noexcept
Definition: juce_CharPointer_UTF8.h:369
bool operator>(CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:71
bool isWhitespace() const noexcept
Definition: juce_CharPointer_UTF8.h:461
CharPointer_UTF8 operator--() noexcept
Definition: juce_CharPointer_UTF8.h:139
int compareIgnoreCase(const CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:422
void writeNull() const noexcept
Definition: juce_CharPointer_UTF8.h:356
bool operator>=(CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:70
static Type findEndOfWhitespace(Type text) noexcept
Definition: juce_CharacterFunctions.h:586
static juce_wchar toLowerCase(juce_wchar character) noexcept
Definition: juce_CharacterFunctions.cpp:40
bool operator!=(CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:67
CharPointer_UTF8 findTerminatingNull() const noexcept
Definition: juce_CharPointer_UTF8.h:324
static size_t getBytesRequiredFor(const juce_wchar charToWrite) noexcept
Definition: juce_CharPointer_UTF8.h:288
CharPointer_UTF8 & operator++() noexcept
Definition: juce_CharPointer_UTF8.h:119
CharPointer_UTF8 operator-(int numToSkip) const noexcept
Definition: juce_CharPointer_UTF8.h:233
CharPointer_UTF8 atomicSwap(const CharPointer_UTF8 newValue)
Definition: juce_CharPointer_UTF8.h:544
static bool isLetterOrDigit(char character) noexcept
Definition: juce_CharacterFunctions.cpp:99
CharType * getAddress() const noexcept
Definition: juce_CharPointer_UTF8.h:74
static juce_wchar toUpperCase(juce_wchar character) noexcept
Definition: juce_CharacterFunctions.cpp:35
static int compare(CharPointerType1 s1, CharPointerType2 s2) noexcept
Definition: juce_CharacterFunctions.h:393
double getDoubleValue() const noexcept
Definition: juce_CharPointer_UTF8.h:494
static bool isLetter(char character) noexcept
Definition: juce_CharacterFunctions.cpp:88
void writeAll(const CharPointer src) noexcept
Definition: juce_CharPointer_UTF8.h:363
int indexOf(const juce_wchar charToFind) const noexcept
Definition: juce_CharPointer_UTF8.h:448
static int indexOf(CharPointerType1 textToSearch, const CharPointerType2 substringToLookFor) noexcept
Definition: juce_CharacterFunctions.h:467
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49
int indexOf(const juce_wchar charToFind, const bool ignoreCase) const noexcept
Definition: juce_CharPointer_UTF8.h:454
bool isLetterOrDigit() const noexcept
Definition: juce_CharPointer_UTF8.h:467
size_t lengthUpTo(const size_t maxCharsToCount) const noexcept
Definition: juce_CharPointer_UTF8.h:265
static int indexOfCharIgnoreCase(Type text, juce_wchar charToFind) noexcept
Definition: juce_CharacterFunctions.h:564
CharPointer_UTF8 operator=(CharPointer_UTF8 other) noexcept
Definition: juce_CharPointer_UTF8.h:53
bool operator<=(CharPointer_UTF8 other) const noexcept
Definition: juce_CharPointer_UTF8.h:68
long long int64
Definition: juce_MathsFunctions.h:60
Definition: juce_Atomic.h:41
Definition: juce_CharPointer_UTF8.h:38
CharPointer_UTF8 operator+(int numToSkip) const noexcept
Definition: juce_CharPointer_UTF8.h:225
static void copyWithCharLimit(DestCharPointerType &dest, SrcCharPointerType src, int maxChars) noexcept
Definition: juce_CharacterFunctions.h:377
static bool isValidString(const CharType *dataToTest, int maxBytesToRead)
Definition: juce_CharPointer_UTF8.h:506
int compare(const CharPointer other) const noexcept
Definition: juce_CharPointer_UTF8.h:402
static int compareIgnoreCaseUpTo(CharPointerType1 s1, CharPointerType2 s2, int maxChars) noexcept
Definition: juce_CharacterFunctions.h:446
void operator-=(int numToSkip) noexcept
Definition: juce_CharPointer_UTF8.h:211
juce_wchar operator*() const noexcept
Definition: juce_CharPointer_UTF8.h:83