Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF8 doesn't work with text styles #2681

Closed
walge-laine opened this issue Dec 27, 2021 · 3 comments · Fixed by #2701
Closed

UTF8 doesn't work with text styles #2681

walge-laine opened this issue Dec 27, 2021 · 3 comments · Fixed by #2701

Comments

@walge-laine
Copy link

I'm using vs2022 and have set /utf-8 option.
Thr example code
fmt::print( "┌{0:─^{2}}┐\n" "│{1: ^{2}}│\n" "└{0:─^{2}}┘\n", "", "Hello, world!", 20);
works fine.
But when I try to add some text style,
fmt::print(fmt::fg(fmt::color::red), "┌{0:─^{2}}┐\n" "│{1: ^{2}}│\n" "└{0:─^{2}}┘\n", "", "Hello, world!", 20);
the output get garbled.

@vitaut
Copy link
Contributor

vitaut commented Dec 27, 2021

What output do you get?

@vitaut
Copy link
Contributor

vitaut commented Dec 28, 2021

Probably the same as #1794. Note that not all versions of windows console support ANSI escape sequences. If this is a different issue please provide more details.

@walge-laine
Copy link
Author

Probably the same as #1794. Note that not all versions of windows console support ANSI escape sequences. If this is a different issue please provide more details.

Sorry but I'm afraid it's not the same issue. To be clear, utf8 characters and text styles works fine individually, but they just cannot be combined.

fmt::print(
    "┌─┐\n"
    "│ │\n"
    "└─┘\n");
fmt::print(fg(fmt::color::red), "hello\n");
fmt::print(bg(fmt::color::green), "hello\n");
fmt::print(fg(fmt::color::red),
    "┌─┐\n"
    "│ │\n"
    "└─┘\n");

image

@vitaut vitaut reopened this Dec 29, 2021
vitaut pushed a commit that referenced this issue Jan 7, 2022
* Fix #2681 - Make detail::print handle UTF-8

* Okay, let's do this Windows-only

* drop extra \0

* yay we can throw!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants