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 copied string corrupt when contain CJK glyphs #543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Windmill-City
Copy link

No description provided.

@dumblob
Copy link
Member

dumblob commented Feb 1, 2023

Technically this looks correct to me. But I am not sure we want to change the API from plain "buffer length" (which we do everywhere, so it is consistent) to UTF-8 specific buffer (which we do not do much if at all).

What do others think here?

If we settle on changing the API, could you also check all other demos to be consistent?

@Windmill-City
Copy link
Author

I am not mean to change the API, but it seems people has mis-use this API, and passes glyphs instead of byte len to this method, so I have to rename the parameter 'len' to 'glyphs'

@Windmill-City
Copy link
Author

And it's more complex to find out the byte len of the utf str for every call to it, so I sugget just change the byte len to glyths for easier use

@Windmill-City
Copy link
Author

I noticed that the --stdC89 fails the CI in opengl3 build, can I change it to --stdC99 to fix this problem, or I change my code to adapt the C89 standard?

@dumblob
Copy link
Member

dumblob commented Feb 3, 2023

I noticed that the --stdC89 fails the CI in opengl3 build, can I change it to --stdC99 to fix this problem, or I change my code to adapt the C89 standard?

We are totally fine with both (though we prefer C89 😉).

I am not mean to change the API, but it seems people has mis-use this API, and passes glyphs instead of byte len to this method, so I have to rename the parameter 'len' to 'glyphs'

Just for my better understanding of your use case - can you make a one-line wrapper of the existing byte-API for your users?

And it's more complex to find out the byte len of the utf str for every call to it, so I sugget just change the byte len to glyths for easier use

Which language are you using Nuklear in? In most languages I know of (except for Swift and a very few others), byte-lengths are the default for (str)len methods/functions.

@Windmill-City
Copy link
Author

Windmill-City commented Feb 4, 2023

edit->clip.copy(edit->clip.userdata, text, end - begin);

Just for my better understanding of your use case - can you make a one-line wrapper of the existing byte-API for your users?

I search for the usage of the copy method, and find the only usage here. It passes glyphs of the selected string, not the byte length.

@Windmill-City
Copy link
Author

Windmill-City commented Feb 4, 2023

Byte length of specific codepoint encoded in UTF-8 varies, the byte length of a 5 glyphs string may varies from 5 to 15. So you need to find out the byte length of the sub string for every call to the copy method. Isn't it more complex to introduce another substring method for utf8 string?

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.

None yet

2 participants