Skip to content

Add xchar support for write_escaped_string. - #2904

Merged
vitaut merged 1 commit into
fmtlib:masterfrom
phprus:ranges-xchar-1
May 27, 2022
Merged

vitaut merged 1 commit into
fmtlib:masterfrom
phprus:ranges-xchar-1

Conversation

@phprus

@phprus phprus commented May 22, 2022

Copy link
Copy Markdown
Contributor

Add xchar support for write_escaped_string.

@phprus phprus mentioned this pull request May 22, 2022
@phprus
phprus marked this pull request as draft May 22, 2022 19:14
@phprus
phprus force-pushed the ranges-xchar-1 branch 3 times, most recently from cc85396 to 474f12f Compare May 22, 2022 19:56
@phprus
phprus marked this pull request as ready for review May 22, 2022 20:03

@vitaut vitaut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Comment thread include/fmt/format.h Outdated
Comment thread include/fmt/format.h Outdated
if (is_utf8()) {
if (escape.cp < 0x100) {
return format_to(out, FMT_STRING("\\x{:02x}"), escape.cp);
return write_codepoint<2>(out, static_cast<Char>('x'), escape.cp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pass prefix as char to have the cast in one place (write_codepoint) instead of each call site.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
@vitaut
vitaut merged commit 1f9eae7 into fmtlib:master May 27, 2022
@vitaut

vitaut commented May 27, 2022

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants