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

Failing on writing Unicode Strings #37

Closed
bolasim opened this issue Sep 6, 2019 · 7 comments
Closed

Failing on writing Unicode Strings #37

bolasim opened this issue Sep 6, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@bolasim
Copy link

bolasim commented Sep 6, 2019

I get the following exception HiveError: String contains non-ASCII characters. whenever I write a Unicode string (currently, I am just trying to store some Arabic text as a String in the database).

Any thoughts on how to fix this? I'm happy to implement the fix if you provide some pointers.

@bolasim bolasim added the bug Something isn't working label Sep 6, 2019
@simc
Copy link
Member

simc commented Sep 6, 2019

Keys have to be ASCII. Could you share a key value pair which is not working?

@bolasim
Copy link
Author

bolasim commented Sep 6, 2019

Nevermind them. I made all the strings ascii and kept the values Unicode and it seems to work well.
Thank you for the quick feedback.

@hamza-sabri
Copy link

how did you do that?
am facing the same problem here whenever am trying to save Arabic string what should I do?

@themisir
Copy link
Contributor

themisir commented Mar 25, 2021

how did you do that?
am facing the same problem here whenever am trying to save Arabic string what should I do?

Hive only accepts ASCII characters as entry keys. But this limitation does not applies to values.

box.put('non-ascii-key', '...');        // will not work
box.put('ascii-key', 'non-ascii-value'); // will work

@viandmarket25
Copy link

viandmarket25 commented Mar 25, 2021

Use this
Make sure to

import 'dart:convert';

Convert your key to ascii code
Eg:
//your key is probably an unaccepted string

Var myKey= key.codeUnitAt(0).toString();
Then,
hiveBox.put(myKey,values);

To retrieve your values Do the same thing,
Var myKey=key.codeUnitAt(0).toString();
Then,
hiveBox.get(myKey);

//results your values

@viandmarket25
Copy link

If it works for you, lemme know if it doesn't also lemme know with your error logs to help better

@themisir
Copy link
Contributor

Anyways posting error logs will help to better understand the issue.

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

5 participants