90 #ifndef LLVM_SUPPORT_CONVERTUTF_H 91 #define LLVM_SUPPORT_CONVERTUTF_H 95 #include <system_error> 116 #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD 117 #define UNI_MAX_BMP (UTF32)0x0000FFFF 118 #define UNI_MAX_UTF16 (UTF32)0x0010FFFF 119 #define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF 120 #define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF 122 #define UNI_MAX_UTF8_BYTES_PER_CODE_POINT 4 124 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE 0xFEFF 125 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE 140 const UTF8** sourceStart,
const UTF8* sourceEnd,
141 UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
148 const UTF8** sourceStart,
const UTF8* sourceEnd,
149 UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
156 const UTF8** sourceStart,
const UTF8* sourceEnd,
157 UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
160 const UTF16** sourceStart,
const UTF16* sourceEnd,
161 UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
164 const UTF32** sourceStart,
const UTF32* sourceEnd,
165 UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
168 const UTF16** sourceStart,
const UTF16* sourceEnd,
169 UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
172 const UTF32** sourceStart,
const UTF32* sourceEnd,
173 UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
184 template <
typename T>
class ArrayRef;
198 char *&ResultPtr,
const UTF8 *&ErrorPtr);
247 const UTF8 *sourceEnd,
249 ConversionFlags flags) {
250 if (*source == sourceEnd)
253 if ((
ptrdiff_t)size > sourceEnd - *source)
296 std::error_code UTF16ToUTF8(
const wchar_t *utf16,
size_t utf16_len,
299 std::error_code UTF16ToCurCP(
const wchar_t *utf16,
size_t utf16_len,
bool hasUTF16ByteOrderMark(ArrayRef< char > SrcBytes)
Returns true if a blob of text starts with a UTF-16 big or little endian byte order mark...
This class represents lattice values for constants.
ConversionResult ConvertUTF8toUTF32(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
Convert a partial UTF8 sequence to UTF32.
ConversionResult ConvertUTF16toUTF8(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
ConversionResult ConvertUTF32toUTF16(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
bool convertWideToUTF8(const std::wstring &Source, std::string &Result)
Converts a std::wstring to a UTF-8 encoded std::string.
unsigned getNumBytesForUTF8(UTF8 firstByte)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool convertUTF8ToUTF16String(StringRef SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
Converts a UTF-8 string into a UTF-16 string with native endianness.
ConversionResult ConvertUTF8toUTF16(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
ConversionResult ConvertUTF32toUTF8(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, char *&ResultPtr, const UTF8 *&ErrorPtr)
Convert an UTF8 StringRef to UTF8, UTF16, or UTF32 depending on WideCharWidth.
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd)
bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr)
Convert an Unicode code point to UTF8 sequence.
Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd)
ConversionResult ConvertUTF8toUTF32Partial(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
Convert a partial UTF8 sequence to UTF32.
ConversionResult convertUTF8Sequence(const UTF8 **source, const UTF8 *sourceEnd, UTF32 *target, ConversionFlags flags)
Convert the first UTF8 sequence in the given source buffer to a UTF32 code point. ...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
ConversionResult ConvertUTF16toUTF32(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
bool convertUTF16ToUTF8String(ArrayRef< char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
StringRef - Represent a constant reference to a string, i.e.