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

Fix convert from UTF-8 to Unicode #123

Merged
merged 2 commits into from
Aug 19, 2024
Merged

Fix convert from UTF-8 to Unicode #123

merged 2 commits into from
Aug 19, 2024

Conversation

cwl769
Copy link
Contributor

@cwl769 cwl769 commented Aug 4, 2024

Before this, we can only display U+0000 to U+07EE, since only 1-byte and 2-byte UTF-8 characters were considered. After this, we can use U+0000 to U+FFFF.
This Pull Request is made to solve issue #122

@@ -331,19 +331,24 @@ uint16_t NanoFont::unicode16FromUtf8(uint8_t ch)
{
#ifdef CONFIG_SSD1306_UNICODE_ENABLE
static uint16_t unicode = 0;
ch &= 0x00FF;
if ( !unicode )
static uint8_t rest = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

rest should not be static and must be placed in if (ch & 0x40) branch

@@ -331,19 +331,24 @@ uint16_t NanoFont::unicode16FromUtf8(uint8_t ch)
{
#ifdef CONFIG_SSD1306_UNICODE_ENABLE
static uint16_t unicode = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Now it is better to move unicode variable inside if (ch & 0x80) branch. Please, check clang compiler results.

Copy link
Owner

@lexus2k lexus2k left a comment

Choose a reason for hiding this comment

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

2 compilation warnings on clang

@cwl769
Copy link
Contributor Author

cwl769 commented Aug 19, 2024

Thanks for your warning. I have made the changes.

rest means how many bytes should be input, so it should be static. Otherwise we have no way of knowing when to finish inputting this character and return a Unicode instead of SSD1306_MORE_CHARS_REQUIRED.

@lexus2k lexus2k merged commit 64aff6b into lexus2k:master Aug 19, 2024
3 of 4 checks passed
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