FE 0.5.0
A header-only C++ library for writing frontends
Loading...
Searching...
No Matches
utf8.h File Reference
#include <cctype>
#include <istream>
#include <ostream>
#include "fe/assert.h"
Include dependency graph for utf8.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fe::utf8::Char32
 Wrapper for char32_t which has a friend ostream operator. More...
 

Namespaces

namespace  fe
 
namespace  fe::utf8
 

Functions

size_t fe::utf8::num_bytes (char8_t c)
 Returns the expected number of bytes for an UTF-8 char sequence by inspecting the first byte.
 
char32_t fe::utf8::append (char32_t c, char32_t b)
 Append b to c for converting UTF-8 to UTF-32.
 
char32_t fe::utf8::first (char32_t c, char32_t num)
 Get relevant bits of first UTF-8 byte c of a multi-byte sequence consisting of num bytes.
 
char8_t fe::utf8::is_valid234 (char8_t c)
 Is the 2nd, 3rd, or 4th byte of an UTF-8 byte sequence valid?
 
char32_t fe::utf8::decode (std::istream &is)
 Decodes the next sequence of bytes from is as UTF-32.
 
bool fe::utf8::encode (std::ostream &os, char32_t c32)
 Encodes the UTF-32 char c32 as UTF-8 and writes the sequence of bytes to os.
 
Wrappers

Safe char32_t-style wrappers for <ctype> functions:

‍Like all other functions from <cctype>, the behavior of std::isalnum is undefined if the argument's value is neither representable as unsigned char nor equal to EOF.

bool fe::utf8::isalnum (char32_t c)
 
bool fe::utf8::isalpha (char32_t c)
 
bool fe::utf8::isblank (char32_t c)
 
bool fe::utf8::iscntrl (char32_t c)
 
bool fe::utf8::isdigit (char32_t c)
 
bool fe::utf8::isgraph (char32_t c)
 
bool fe::utf8::islower (char32_t c)
 
bool fe::utf8::isprint (char32_t c)
 
bool fe::utf8::ispunct (char32_t c)
 
bool fe::utf8::isspace (char32_t c)
 
bool fe::utf8::isupper (char32_t c)
 
bool fe::utf8::isxdigit (char32_t c)
 
bool fe::utf8::isascii (char32_t c)
 
char32_t fe::utf8::tolower (char32_t c)
 
char32_t fe::utf8::toupper (char32_t c)
 
bool fe::utf8::isrange (char32_t c, char32_t begin, char32_t finis)
 Is c within [begin, finis]?
 
auto fe::utf8::isrange (char32_t begin, char32_t finis)
 
bool fe::utf8::isodigit (char32_t c)
 Is octal digit?
 
bool fe::utf8::isbdigit (char32_t c)
 Is binary digit?
 
any

Is c in any of the remaining arguments?

bool fe::utf8::_any (char32_t c, char32_t d)
 
template<class... T>
bool fe::utf8::_any (char32_t c, char32_t d, T... args)
 
template<class... T>
auto fe::utf8::any (T... args)
 

Variables

static constexpr size_t fe::utf8::Max = 4
 Maximal number of char8_ts of an UTF-8 byte sequence.
 
static constexpr char32_t fe::utf8::BOM = 0xfeff
 Byte Order Mark.
 
static constexpr char32_t fe::utf8::EoF = (char32_t)std::istream::traits_type::eof()
 End of File.
 
static constexpr char32_t fe::utf8::Null = 0