From 4b7c87a9b53f5317e9f7982bd779d53a66960bdc Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 16 Aug 2026 00:58:38 +0200 Subject: Support UTF-8 strings --- include/elna/boot/driver.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/elna/boot/driver.h b/include/elna/boot/driver.h index 9076e23..45e2e40 100644 --- a/include/elna/boot/driver.h +++ b/include/elna/boot/driver.h @@ -45,15 +45,31 @@ namespace elna::boot constexpr char escape_invalid_char = '\xff'; - char escape_char(char escape); /** - * Replaces both \r\n sequences and lone \r characters with \n. - * Modifies the original input. + * Parses a character literal and produces code point integer + * representation. * - * \param string Text to normalize. + * \param escape Text to parse. + * \return Code point. */ - void normalize_newlines(std::string& string); - std::optional escape_string(const char *escape); + std::optional parse_character_literal(const char *escape); + + /** + * Parses and unescapes a single byte character. Fails if the input inside + * single quotes contains more than a single character. Rejects unicode. + * + * \param escape Text to unescape. + * \return Unescaped character. + */ + std::optional parse_byte_literal(const char *escape); + + /** + * Parses and unescapes a string. + * + * \param escape Text to unescape. + * \return Unescaped string. + */ + std::optional parse_string_literal(const char *escape); template std::optional, integer_sign>> -- cgit v1.2.3