41#ifndef FORTRAN_RUNTIME_UTF_H_
42#define FORTRAN_RUNTIME_UTF_H_
44#include "flang/Common/optional.h"
48namespace Fortran::runtime {
52RT_OFFLOAD_VAR_GROUP_BEGIN
53extern const RT_CONST_VAR_ATTRS std::uint8_t UTF8FirstByteTable[256];
54static constexpr std::size_t maxUTF8Bytes{7};
55RT_OFFLOAD_VAR_GROUP_END
57static inline RT_API_ATTRS std::size_t MeasureUTF8Bytes(
char first) {
58 return UTF8FirstByteTable[
static_cast<std::uint8_t
>(first)];
61RT_API_ATTRS std::size_t MeasurePreviousUTF8Bytes(
62 const char *end, std::size_t limit);
66RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(
const char *);
70RT_API_ATTRS std::size_t EncodeUTF8(
char *,
char32_t);