WPILibC++ 2023.4.3
ConvertUTF.h File Reference
#include <span>
#include <cstddef>
#include <string>
#include <string_view>
#include <system_error>

Go to the source code of this file.

Namespaces

namespace  wpi
 /file This file defines the SmallVector class.
 

Macros

#define UNI_REPLACEMENT_CHAR   (UTF32)0x0000FFFD
 
#define UNI_MAX_BMP   (UTF32)0x0000FFFF
 
#define UNI_MAX_UTF16   (UTF32)0x0010FFFF
 
#define UNI_MAX_UTF32   (UTF32)0x7FFFFFFF
 
#define UNI_MAX_LEGAL_UTF32   (UTF32)0x0010FFFF
 
#define UNI_MAX_UTF8_BYTES_PER_CODE_POINT   4
 
#define UNI_UTF16_BYTE_ORDER_MARK_NATIVE   0xFEFF
 
#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED   0xFFFE
 

Typedefs

typedef unsigned int wpi::UTF32
 
typedef unsigned short wpi::UTF16
 
typedef unsigned char wpi::UTF8
 
typedef bool wpi::Boolean
 

Enumerations

enum  wpi::ConversionResult { wpi::conversionOK , wpi::sourceExhausted , wpi::targetExhausted , wpi::sourceIllegal }
 
enum  wpi::ConversionFlags { wpi::strictConversion = 0 , wpi::lenientConversion }
 

Functions

ConversionResult wpi::ConvertUTF8toUTF16 (const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
 
ConversionResult wpi::ConvertUTF8toUTF32Partial (const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
 Convert a partial UTF8 sequence to UTF32. More...
 
ConversionResult wpi::ConvertUTF8toUTF32 (const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
 Convert a partial UTF8 sequence to UTF32. More...
 
ConversionResult wpi::ConvertUTF16toUTF8 (const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
 
ConversionResult wpi::ConvertUTF32toUTF8 (const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
 
ConversionResult wpi::ConvertUTF16toUTF32 (const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
 
ConversionResult wpi::ConvertUTF32toUTF16 (const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
 
Boolean wpi::isLegalUTF8Sequence (const UTF8 *source, const UTF8 *sourceEnd)
 
Boolean wpi::isLegalUTF8String (const UTF8 **source, const UTF8 *sourceEnd)
 
unsigned wpi::getNumBytesForUTF8 (UTF8 firstByte)
 
bool wpi::ConvertUTF8toWide (unsigned WideCharWidth, std::string_view Source, char *&ResultPtr, const UTF8 *&ErrorPtr)
 Convert an UTF8 string_view to UTF8, UTF16, or UTF32 depending on WideCharWidth. More...
 
bool wpi::ConvertUTF8toWide (std::string_view Source, std::wstring &Result)
 Converts a UTF-8 string_view to a std::wstring. More...
 
bool wpi::ConvertUTF8toWide (const char *Source, std::wstring &Result)
 Converts a UTF-8 C-string to a std::wstring. More...
 
bool wpi::convertWideToUTF8 (const std::wstring &Source, SmallVectorImpl< char > &Result)
 Converts a std::wstring to a UTF-8 encoded std::string. More...
 
bool wpi::ConvertCodePointToUTF8 (unsigned Source, char *&ResultPtr)
 Convert an Unicode code point to UTF8 sequence. More...
 
ConversionResult wpi::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. More...
 
bool wpi::hasUTF16ByteOrderMark (std::span< const char > SrcBytes)
 Returns true if a blob of text starts with a UTF-16 big or little endian byte order mark. More...
 
bool wpi::convertUTF16ToUTF8String (std::span< const char > SrcBytes, SmallVectorImpl< char > &Out)
 Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string. More...
 
bool wpi::convertUTF16ToUTF8String (std::span< const UTF16 > Src, SmallVectorImpl< char > &Out)
 Converts a UTF16 string into a UTF8 std::string. More...
 
bool wpi::convertUTF8ToUTF16String (std::string_view SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
 Converts a UTF-8 string into a UTF-16 string with native endianness. More...
 

Macro Definition Documentation

◆ UNI_MAX_BMP

#define UNI_MAX_BMP   (UTF32)0x0000FFFF

◆ UNI_MAX_LEGAL_UTF32

#define UNI_MAX_LEGAL_UTF32   (UTF32)0x0010FFFF

◆ UNI_MAX_UTF16

#define UNI_MAX_UTF16   (UTF32)0x0010FFFF

◆ UNI_MAX_UTF32

#define UNI_MAX_UTF32   (UTF32)0x7FFFFFFF

◆ UNI_MAX_UTF8_BYTES_PER_CODE_POINT

#define UNI_MAX_UTF8_BYTES_PER_CODE_POINT   4

◆ UNI_REPLACEMENT_CHAR

#define UNI_REPLACEMENT_CHAR   (UTF32)0x0000FFFD

◆ UNI_UTF16_BYTE_ORDER_MARK_NATIVE

#define UNI_UTF16_BYTE_ORDER_MARK_NATIVE   0xFEFF

◆ UNI_UTF16_BYTE_ORDER_MARK_SWAPPED

#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED   0xFFFE