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

Strings' max lengths should be not in bytes, but in characters #218

Open
maximmax42 opened this issue Nov 17, 2022 · 4 comments
Open

Strings' max lengths should be not in bytes, but in characters #218

maximmax42 opened this issue Nov 17, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@maximmax42
Copy link
Contributor

maximmax42 commented Nov 17, 2022

Consider this string of 128 Cyrillic letters а:
аааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааа
Counting in UTF-8 bytes, it's 256 bytes long, and yet, if I replace byte check in the library with a simple length comparison, it works just fine:
image

Here's a string that has 64 Cyrillic а's and 64 Latin b's:
ааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааааbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Byte length would be 192, but character length is still 128, so it also works just fine:
image

I've also tested if other people see the presence with those strings, and they do.

Thought up of another test, Zalgo. Consider this string:
GitHub removes Zalgo text so here's a link to the string instead
206 bytes, 110 characters. Under 128 character, so it works:
image

@maximmax42 maximmax42 changed the title String's max lengths should be not in bytes, but in characters Strings' max lengths should be not in bytes, but in characters Nov 17, 2022
@Lachee Lachee added the bug Something isn't working label Nov 21, 2022
@Lachee
Copy link
Owner

Lachee commented Nov 21, 2022

I'll look into this on my end. I will have to verify the API response because when this was first implemented it was byte count.

@maximmax42
Copy link
Contributor Author

Yeah, it was probably changed, and it's not mentioned anywhere. Old page for this API still says 128 bytes, but it also says image names can be no more than 32 bytes, which we know isn't true anymore.

@maximmax42
Copy link
Contributor Author

Oh and also, API doesn't accept text fields that are exactly 1 character, needs to be 2 or more.

@maximmax42
Copy link
Contributor Author

maximmax42 commented Dec 21, 2022

An update: while button labels accept 32 any characters even if it's more than 32 bytes, putting a label with 32+ bytes still causes the whole presence to not show for others.

Discord Moment:tm:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants