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

About Support for Full width Characters in FTXUI #865

Open
hcwanz opened this issue May 14, 2024 · 10 comments
Open

About Support for Full width Characters in FTXUI #865

hcwanz opened this issue May 14, 2024 · 10 comments

Comments

@hcwanz
Copy link

hcwanz commented May 14, 2024

I noticed that there are functions in FTXUI that support wchar, such as wstring_width, but I haven't found any applications for these functions.
When I tried to print "测试" in examples/dom/border.cpp, only a bunch of messy codes were printed.
So I would like to ask what kind of support FTXUI has for full-width characters:

  1. It has been supported, but my usage is incorrect?
  2. Will it be supported in the future?
  3. Or do users need to make some modifications to FTXUI themselves?
@ArthurSonzogni
Copy link
Owner

Hello!

Full width characters are supporters.

What terminal are you using? Maybe your terminal doesn't support rendering them?

See my test on examples/dom/border.cpp
image

You can try the example examples/component/input.cpp demo on your terminal and input some full width characters.

@hcwanz
Copy link
Author

hcwanz commented May 14, 2024

It seems like it's really my problem here

@ArthurSonzogni
Copy link
Owner

Maybe ;-)
What OS and terminal are you using?

@hcwanz
Copy link
Author

hcwanz commented May 14, 2024

windows &&windows terminal
When using _getch normally, you can input display full width characters.
But in input.cpp, when entering, only garbled characters will be displayed.

@hcwanz
Copy link
Author

hcwanz commented May 15, 2024

1

@hcwanz
Copy link
Author

hcwanz commented May 15, 2024

Not all of them will output messy codes.
"当饭森" will only display "森";
森
"埏埴" can be displayed normally, and even some subsequent characters can be displayed normally, but the “,当” cannot be displayed.
埏埴
The "测试" will display garbled text
测试

@hcwanz
Copy link
Author

hcwanz commented May 15, 2024

When I output them individually using string, they can be output normally
image

@hcwanz
Copy link
Author

hcwanz commented May 16, 2024

Maybe ;-) What OS and terminal are you using?

It seems that the text determination in EatCodePoint is not correct in my environment.
As shown in the figure below, ',' in string is '1010 0011 1010 1100', which is indeed 2 bytes, but it is different from the judgment in the function.
May I ask why this is the case.
1

@ArthurSonzogni
Copy link
Owner

In UTF8, we considers ", " to be two 1-byte characters:

  • 00101100 => ','
  • 00100000 => ' '

Not all of them will output messy codes.
"当饭森" will only display "森";

"埏埴" can be displayed normally, and even some subsequent characters can be displayed normally, but the “,当” cannot be displayed.

I checked locally on Linux:

image

It was working correctly.

I guess I should try on Microsoft Windows terminal. Thanks for your useful input!

@hcwanz
Copy link
Author

hcwanz commented May 16, 2024

... I know there's an error. Chinese characters should occupy 3 bytes in utf8, and the default encoding for window is gbk.
When Chinese characters occupy two bytes, it indicates that they are not in utf8 format.

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

2 participants