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.
Keys have to be ASCII. Could you share a key value pair which is not working?
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.
how did you do that?
am facing the same problem here whenever am trying to save Arabic string what should I do?
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
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
If it works for you, lemme know if it doesn't also lemme know with your error logs to help better
Anyways posting error logs will help to better understand the issue.