Skip to content

Commit 2f9afef

Browse files
committed
Replace unicode with byte
1 parent b0df9d2 commit 2f9afef

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

cpp2rust/converter/converter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,9 +1707,8 @@ bool Converter::VisitFloatingLiteral(clang::FloatingLiteral *expr) {
17071707

17081708
bool Converter::VisitCharacterLiteral(clang::CharacterLiteral *expr) {
17091709
auto uc = static_cast<unsigned char>(expr->getValue());
1710-
std::string ch = uc > 0x7F
1711-
? std::format("'\\u{{{:x}}}'", uc)
1712-
: "'" + GetEscapedCharLiteral(expr->getValue()) + "'";
1710+
std::string ch = GetEscapedCharLiteral(expr->getValue());
1711+
ch = (uc > 0x7F ? "b'" : "'") + std::move(ch) + "'";
17131712
{
17141713
PushParen paren(*this);
17151714
StrCat(ch, keyword::kAs, ToStringBase(expr->getType()));

tests/unit/out/refcount/string_escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main_0() -> i32 {
5555
124_u8,
5656
125_u8,
5757
126_u8,
58-
('\u{ff}' as u8),
58+
(b'\xff' as u8),
5959
])));
6060
);
6161
let i: Value<i32> = Rc::new(RefCell::new(0));

tests/unit/out/unsafe/string_escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ unsafe fn main_0() -> i32 {
5656
124_u8,
5757
125_u8,
5858
126_u8,
59-
('\u{ff}' as u8),
59+
(b'\xff' as u8),
6060
]
6161
};;
6262
let mut i: i32 = 0;

0 commit comments

Comments
 (0)