json_pack_cstr_len currently assumes that input is ASCII. This is clearly the wrong assumption. The code needs to iterate over the unicode codepoints instead.
json_pack_cstr_len
I have a WIP that needs more testing.