[Koha-bugs] [Bug 8375] Common diacritics not shown correctly when exporting batch label to PDF
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Jul 19 15:35:24 CEST 2012
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8375
--- Comment #12 from Dobrica Pavlinusic <dpavlin at rot13.org> ---
I'm getting
Wide character in compress at /usr/share/perl5/PDF/Reuse.pm line 825.
errors when I try to use label printing with utf-8 characters (with or without
this patch).
However, when changing utf8::decode to utf8::encode in this patch, everything
works. Let me try to explain why:
PDF::Reuse does binmode on it's file-handle so we shouldn't pass any utf-8
characters ("wide characters") to it. However, this patch proposes using
utf8::decode which (according to perldoc utf8) does:
· $success = utf8::decode($string)
Attempts to convert in-place the octet sequence in UTF-X to the
corresponding character sequence. The UTF-8 flag is turned on
only if the source string contains multiple-byte UTF-X characters.
If $string is invalid as UTF-X, returns false; otherwise
returns true.
So decode is used when we are converting bytes into utf-8 strings, not the
other way around.
However, utf8::encode does exactly what we need:
· utf8::encode($string)
Converts in-place the character sequence to the corresponding octet
sequence in UTF-X. The UTF8 flag is turned off, so that
after this operation, the string is a byte string. Returns nothing.
Which is exactly why I'm proposing to change this patch to use encode instead
of decode.
I guess that this patch has passed sign-off and QA because it's a special case:
We are not correctly converting latin-1 characters into utf-8 when using Z39.50
search, so we get utf-8 marked string which contains latin1 umlauts inside it.
In that case, utf8::decode correctly strips utf-8 flag and everything works,
but this change also breaks real string which have utf-8 characters in them.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list