https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24606
--- Comment #66 from Marcel de Rooy <[email protected]> --- The following follow-up looks highly arguable to me: Bug 24606: Fix encoding issues on decoded content - return decode_json( $self->contents ) if $self->contents; + return decode_json( encode_utf8($self->contents) ) if $self->contents; Note a few lines above (in ->store): if ( ref( $self->contents ) eq 'HASH' ) { $self->contents( encode_json( $self->contents ) ); } The reference to "Do it yourself" in the commit message is not very specific and out of its context. Since we are storing strings to the database here, I think we should refer the utf8 encoding to that layer. And we should encode/decode in the middle of the process. So I would quote another part of the JSON docs: utf8 flag disabled When utf8 is disabled (the default), then encode/decode generate and expect Unicode strings, that is, characters with high ordinal Unicode values (> 255) will be encoded as such characters, and likewise such characters are decoded as-is, no changes to them will be done, except "(re-)interpreting" them as Unicode codepoints or Unicode characters, respectively (to Perl, these are the same thing in strings unless you do funny/weird/dumb stuff). This is useful when you want to do the encoding yourself (e.g. when you want to have UTF-16 encoded JSON texts) or when some other layer does the encoding for you (for example, when printing to a terminal using a filehandle that transparently encodes to UTF-8 you certainly do NOT want to UTF-8 encode your data first and have Perl encode it another time). What does practically mean? You should switch from using decode_json and encode_json TO from_json and to_json. Leave the strings in Perl internal format during the process. encode_json Converts the given Perl data structure to a UTF-8 encoded, binary string. to_json Converts the given Perl data structure to a Unicode string by default. This needs further attention imo. (But cant fail it anymore :) -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
