utf8.hpp
Go to the documentation of this file.
#pragma once
#include <iostream> // std::cout, debug
#include <restinio/string_view.hpp>
#include <restinio/utils/utf8_checker.hpp>
namespace restinio
{
namespace websocket
{
namespace basic
{
namespace impl
{
//
// check_utf8_is_correct
//
inline bool
check_utf8_is_correct( string_view_t sv ) noexcept
{
restinio::utils::utf8_checker_t checker;
for( const auto & ch : sv )
{
if( !checker.process_byte( static_cast<std::uint8_t>(ch) ) )
{
return false;
}
}
return checker.finalized();
}
} /* namespace impl */
} /* namespace basic */
} /* namespace websocket */
} /* namespace restinio */
restinio::utils::utf8_checker_t
Helper class for checking UTF-8 byte sequence during parsing URI or incoming byte stream.
Definition: utf8_checker.hpp:35
restinio::utils::utf8_checker_t::finalized
RESTINIO_NODISCARD bool finalized() const noexcept
Definition: utf8_checker.hpp:120
restinio::utils::utf8_checker_t::process_byte
RESTINIO_NODISCARD bool process_byte(std::uint8_t byte) noexcept
Definition: utf8_checker.hpp:41
restinio::websocket::basic::impl::check_utf8_is_correct
bool check_utf8_is_correct(string_view_t sv) noexcept
Definition: utf8.hpp:29
restinio
Definition: asio_include.hpp:21
restinio::string_view_t
nonstd::string_view string_view_t
Definition: string_view.hpp:19
string_view.hpp
utf8_checker.hpp
An implementation of checker for UTF-8 sequences.