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

Handle utf8 character as a fill character in alignment #1109

Closed
dsvi opened this issue Apr 8, 2019 · 5 comments
Closed

Handle utf8 character as a fill character in alignment #1109

dsvi opened this issue Apr 8, 2019 · 5 comments

Comments

@dsvi
Copy link

dsvi commented Apr 8, 2019

If you use unicode symbols as fill character for alignment, you get runtime error
for example, for:
print(u8" {:─<5}─{}\n", i, str);
there supposed to be outputs like this

 0─────2019 March 27 06:32:41                                                                                                                                                 
 1─────2019 March 27 14:43:20                                                                                                                                                 

but there is runtime error:
missing '}' in format string

@vitaut
Copy link
Contributor

vitaut commented Apr 10, 2019

Thanks for reporting. This is a known limitation: only single code units can be used in the fill field at the moment.

vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, and remove legacy setters (#940).
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, and remove legacy setters (#940).
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, and remove legacy setters (#940).
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, and remove legacy setters (#940).
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, and remove legacy setters (#940).
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, and remove legacy setters (#940).
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, remove legacy setters (#940), and
optimize layout.
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, remove legacy setters (#940), and
optimize layout.
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, remove legacy setters (#940), and
optimize layout.
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, remove legacy setters (#940), and
optimize layout.
vitaut added a commit that referenced this issue Jul 7, 2019
Refactor `format_specs` and related APIs to support variable-width fill
(#1109), improve naming consistency, remove legacy setters (#940), and
optimize layout.
@vitaut
Copy link
Contributor

vitaut commented Jul 26, 2019

format_specs can accommodate multibyte specs as of e4f84ee, but need to hook this to the parsing and formatting logic.

@vitaut
Copy link
Contributor

vitaut commented Jan 19, 2020

{fmt} now supports UTF-8 code points as fill. For example

#include <fmt/core.h>

int main() {
  fmt::print(" {:─<5}─{}\n", 0, "2019 March 27 06:32:41");
}

prints

 0─────2019 March 27 06:32:41

as expected.

@vitaut vitaut closed this as completed Jan 19, 2020
@gocarlos
Copy link

should this work out of the box?

this code:

  fmt::print(
                  "┌{0:─^{2}}┐\n"
                  "│{1: ^{2}}│\n"
                  "└{0:─^{2}}┘\n", "", "my great message.", 72);
  fmt::print(" {:─<5}─{}\n", 0, "2019 March 27 06:32:41");

creates this on windows
image

@vitaut
Copy link
Contributor

vitaut commented Jun 27, 2020

You should compile with /utf-8, otherwise MSVC will corrupt your string literals.

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

No branches or pull requests

3 participants