-
Notifications
You must be signed in to change notification settings - Fork 409
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
Extended ASCII characters #412
Comments
Hive supports UTF-8 characters for values and ASCII for keys. The reason is that decoding ASCII characters is A LOT faster in Dart than decoding UTF-8 which improves Box opening times significantly. Edit: ASCII only has 127 characters. Everything beyond is UTF-8. |
Thanks a lot for your reply! Do you know any good ways of converting UTF-8 to ASCII in dart/flutter? I'm thinking about just converting the key right before reading/writing in Hive, for instance replacing any invalid character with \xx. Best regards |
I recommend using the |
.chars or .characters converts from string to a list of unicode char. I don't understand how to get to ascii from there. I am trying to use as a key a list of bytes, converting it somehow to unicode, but I keep bumping in conversion errors or invalid characters. |
Another solution that allows you to use any character is to use base64-encoding, so both when you read or write you can use the encoded key. final String encodedKey = base64.encode(utf8.encode(key));
box.put(encodedKey, json); |
Question
I'm running into an issue where characters like 'ö' throwing an error, then I noticed this part in the code:
Is there a reason to not include all 255 ASCII characters?
Best regards
The text was updated successfully, but these errors were encountered: