105#ifndef WPIUTIL_WPI_CONVERTUTF_H
106#define WPIUTIL_WPI_CONVERTUTF_H
111#include <string_view>
112#include <system_error>
133#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
134#define UNI_MAX_BMP (UTF32)0x0000FFFF
135#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
136#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
137#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
139#define UNI_MAX_UTF8_BYTES_PER_CODE_POINT 4
141#define UNI_UTF16_BYTE_ORDER_MARK_NATIVE 0xFEFF
142#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
144#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE 0x0000FEFF
145#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE0000
160 const UTF8** sourceStart,
const UTF8* sourceEnd,
168 const UTF8** sourceStart,
const UTF8* sourceEnd,
176 const UTF8** sourceStart,
const UTF8* sourceEnd,
180 const UTF16** sourceStart,
const UTF16* sourceEnd,
184 const UTF32** sourceStart,
const UTF32* sourceEnd,
188 const UTF16** sourceStart,
const UTF16* sourceEnd,
192 const UTF32** sourceStart,
const UTF32* sourceEnd,
218 char *&ResultPtr,
const UTF8 *&ErrorPtr);
267 const UTF8 *sourceEnd,
273 if ((ptrdiff_t)size > sourceEnd - *
source)
334std::error_code UTF16ToUTF8(
const wchar_t *utf16,
size_t utf16_len,
337std::error_code UTF16ToCurCP(
const wchar_t *utf16,
size_t utf16_len,
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation source
Definition: ThirdPartyNotices.txt:111
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:579
basic_string_view< char > string_view
Definition: core.h:501
Definition: ntcore_cpp.h:26
bool convertUTF8ToUTF16String(std::string_view SrcUTF8, SmallVectorImpl< UTF16 > &DstUTF16)
Converts a UTF-8 string into a UTF-16 string with native endianness.
bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr)
Convert an Unicode code point to UTF8 sequence.
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd)
ConversionResult ConvertUTF32toUTF16(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
bool 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.
unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd)
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.
Definition: ConvertUTF.h:266
ConversionResult ConvertUTF8toUTF16(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
bool convertWideToUTF8(const std::wstring &Source, SmallVectorImpl< char > &Result)
Converts a std::wstring to a UTF-8 encoded std::string.
bool 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.
unsigned getNumBytesForUTF8(UTF8 firstByte)
bool convertUTF32ToUTF8String(std::span< const char > SrcBytes, std::string &Out)
Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
ConversionResult ConvertUTF32toUTF8(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
ConversionResult ConvertUTF16toUTF32(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
ConversionResult ConvertUTF8toUTF32Partial(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
Convert a partial UTF8 sequence to UTF32.
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)
Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd)
bool convertUTF16ToUTF8String(std::span< const char > SrcBytes, SmallVectorImpl< char > &Out)
Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
unsigned char UTF8
Definition: ConvertUTF.h:129
unsigned short UTF16
Definition: ConvertUTF.h:128
flags
Definition: http_parser.h:206
ConversionFlags
Definition: ConvertUTF.h:154
@ lenientConversion
Definition: ConvertUTF.h:156
@ strictConversion
Definition: ConvertUTF.h:155
unsigned int UTF32
Definition: ConvertUTF.h:127
ConversionResult
Definition: ConvertUTF.h:147
@ sourceIllegal
Definition: ConvertUTF.h:151
@ sourceExhausted
Definition: ConvertUTF.h:149
@ conversionOK
Definition: ConvertUTF.h:148
@ targetExhausted
Definition: ConvertUTF.h:150
bool Boolean
Definition: ConvertUTF.h:130