To avoid web browser errors, all JSON encoded strings returned by MIDAS must be valid UTF-8 unicode. By extension, this means that all ODB strings (TID_STRING values, key names, etc) must be valid UTF-8 unicode.
I believe ODB key names are already checked for this at creation time (db_create() & co), but I am not sure db_validate() checks for this.
I think ODB TID_STRING values are not checked right now. db_validate() should have this check. db_set_value() & co probably should have this check.
If invalid UTF-8 sequences are found, we should at least complain about it. But I am not sure if we can fix them automatically.