mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Shell: Add support for \uhhhhhhhh escapes in strings
This will be replaced with the unicode character whose codepoint is given by the unsigned 32-bit number 'hhhhhhhh' (hex).
This commit is contained in:
parent
0f03960c1b
commit
22b244df45
3 changed files with 16 additions and 2 deletions
|
@ -1315,6 +1315,18 @@ RefPtr<AST::Node> Parser::parse_doublequoted_string_inner()
|
|||
builder.append(to_byte(first_nibble, second_nibble));
|
||||
break;
|
||||
}
|
||||
case 'u': {
|
||||
if (m_input.length() <= m_offset + 8)
|
||||
break;
|
||||
size_t counter = 8;
|
||||
auto chars = consume_while([&](auto) { return counter-- > 0; });
|
||||
if (auto number = AK::StringUtils::convert_to_uint_from_hex(chars); number.has_value())
|
||||
builder.append(Utf32View { &number.value(), 1 });
|
||||
else
|
||||
builder.append(chars);
|
||||
|
||||
break;
|
||||
}
|
||||
case 'a':
|
||||
builder.append('\a');
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue