I am working with
Inline::Python. In order to pass string data into Python, I am calling
Data::Structure::Util::utf8_on() on all the data I am passing into any function call that is Python. It seems to work well except for the hash keys. Python complains: "TypeError: keys must be str, int, float, bool or None, not bytes at line 39". Turns out that in that module
(sample here), only the values are set to utf8, not the keys.
Is there a way to set the keys to utf8 in XS? I was hoping for a HeKEY macro, but doing some poking around, I only see keys being retrieved, not set.
Failing that, would a simple:
my %newhash;
for (keys %oldhash) {
$newhash{utf8_on($_)} = $newhash{$_};
}
call_pyfunc(\%newhash);
seem to be the right thing to do?
Thank you.