<div dir="ltr">Excellent catch, David!<div><br></div><div>Please file a bug for that, if you haven't already, the use of MARC 880 for CJK languages is quite common in US libraries.</div><div><br></div><div>Does Zebra handle 4 byte characters correctly?</div><div><br></div><div>--Barton</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 24, 2017 at 2:08 AM, David Cook <span dir="ltr"><<a href="mailto:dcook@prosentient.com.au" target="_blank">dcook@prosentient.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-AU" link="#0563C1" vlink="#954F72"><div class="m_5073320629946847830WordSection1"><p class="MsoNormal">Hi all,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I ran into a problem this afternoon where MySQL was silently truncating my UTF8 encoded string in biblio_metadata.metadata and biblio.notes. Admittedly, the string had some funny looking data*, but it was all valid UTF8. I had zero problems with XML::LibXML or MARC::Record. However, whenever I would use DBI or the mysql command line client, I’d get a truncated string**. This meant a completely invalid XML record which is irretrievable from the database using Koha’s XML handling methods. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">However, I eventually found <a href="https://bugs.mysql.com/bug.php?id=53005" target="_blank">https://bugs.mysql.com/bug.<wbr>php?id=53005</a> where they state that the MySQL ‘utf8’ charset has a 3 byte limit (<a href="https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8.html" target="_blank">https://dev.mysql.com/doc/<wbr>refman/5.7/en/charset-unicode-<wbr>utf8.html</a>). That tends to be fine in most cases, but <span style="font-family:"Cambria Math",serif">𝔤 </span>is 4 bytes (f0 9d 94 a4 <a href="http://dev.networkerror.org/utf8/?start=120100&end=120200&cols=4&show_uni_int=on&show_uni_hex=on&show_html_ent=on&show_raw_hex=on&show_raw_bin=on" target="_blank">http://dev.networkerror.org/<wbr>utf8/?start=120100&end=120200&<wbr>cols=4&show_uni_int=on&show_<wbr>uni_hex=on&show_html_ent=on&<wbr>show_raw_hex=on&show_raw_bin=<wbr>on</a>). It was on this character that the truncation happened. Apparently, there is a 4 byte UTF-8 charset called utf8mb4: <a href="https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html" target="_blank">https://dev.mysql.com/doc/<wbr>refman/5.7/en/charset-unicode-<wbr>utf8mb4.html</a>. If you “SET NAMES = ‘utf8mb4’” for your client and set the charset for your database column, that will allow you to correctly insert the data. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">So the truncation doesn’t generate an error but it does generate a warning, which is much more obvious in the mysql CLI client than when using DBI:<u></u><u></u></p><p class="MsoNormal">MariaDB [devkohadcook]> update biblio set abstract = 'We introduce a new perspective and a generalization of spectral networks for 4d N=2" style="position: relative;" tabindex="0" id="MathJax-Element-1-Frame" class="MathJax"&gt;<span lang="EN-US"></span>=2 theories of class S" style="position: relative;" tabindex="0" id="MathJax-Element-2-Frame" class="MathJax"&gt;<span lang="EN-US"></span> associated to Lie algebras g=An" style="position: relative;" tabindex="0" id="MathJax-Element-3-Frame" class="MathJax"&gt;<span style="font-family:"Cambria Math",serif">𝔤</span>=An, Dn" style="position: relative;" tabindex="0" id="MathJax-Element-4-Frame" class="MathJax"&gt;Dn, E6" style="position: relative;" tabindex="0" id="MathJax-Element-5-Frame" class="MathJax"&gt;E6, and E7" style="position: relative;" tabindex="0" id="MathJax-Element-6-Frame" class="MathJax"&gt;E7. Spectral networks directly compute the BPS spectra of 2d theories on surface defects coupled to the 4d theories. A Lie algebraic interpretation of these spectra emerges naturally from our construction, leading to a new description of 2d-4d wall-crossing phenomena. Our construction also provides an efficient framework for the study of BPS spectra of the 4d theories. In addition, we consider novel types of surface defects associated with minuscule representations of g" style="position: relative;" tabindex="0" id="MathJax-Element-7-Frame" class="MathJax"&gt;<span style="font-family:"Cambria Math",serif">𝔤</span>.' where biblionumber = 50314;<u></u><u></u></p><p class="MsoNormal">Query OK, 0 rows affected, 1 warning (0.00 sec)<u></u><u></u></p><p class="MsoNormal">Rows matched: 1  Changed: 0  Warnings: 1<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Because it doesn’t raise an exception, I’d say it’s silent. You have to check for it. Using mysql, you can send “SHOW WARNINGS” after the insert query and you can see something like:<u></u><u></u></p><p class="MsoNormal">+---------+------+------------<wbr>------------------------------<wbr>------------------------------<wbr>--------+<u></u><u></u></p><p class="MsoNormal">| Level   | Code | Message                       <wbr>                                     <wbr>            |<u></u><u></u></p><p class="MsoNormal">+---------+------+------------<wbr>------------------------------<wbr>------------------------------<wbr>--------+<u></u><u></u></p><p class="MsoNormal">| Warning | 1366 | Incorrect string value: '\xF0\x9D\x94\xA4=A...' for column 'abstract' at row 1 |<u></u><u></u></p><p class="MsoNormal">+---------+------+------------<wbr>------------------------------<wbr>------------------------------<wbr>--------+<u></u><u></u></p><p class="MsoNormal">1 row in set (0.01 sec)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">With DBI, it’s harder: <a href="http://stackoverflow.com/questions/7946655/dbi-perl-logging-mysql-warnings" target="_blank">http://stackoverflow.com/<wbr>questions/7946655/dbi-perl-<wbr>logging-mysql-warnings</a>. Apparently you can use $dbh->{mysql_warning_count} to check for warnings, and then send “SHOW WARNINGS” via the same database handle and that should give you your warning result. Or you can run MySQL in “traditional” mode which treats warnings as errors. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">So this seems like an edgecase… it’s some wonky data (albeit valid UTF8 data) in an otherwise English record. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">However, according to MySQL (I haven’t verified for myself), Chinese, Japanese, and Korean sometimes use 4 bytes for characters. So people using these languages with Koha could be getting truncated data without realising that’s what is happening or why.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I’ve tried out utf8mb4 and it works great. I think the downside is that it uses more space for certain types of columns because it needs to allocate more space for that 4<sup>th</sup> byte. I don’t know whether we should consider switching from utf8 to utf8mb4, so that we’re inclusive of CJK and comply with RFC3629 which states that there’s a 4 byte maximum.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I think it’s worth discussion though. This wouldn’t just affect libraries in Asia. It would affect any library which stores records with CJK characters in a MARC 880 “Alternate Graphic Representation” field. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I’m at the end of my Friday work day, so I’m going to leave it there, but food for thought!<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">*Aforementioned strange data:<u></u><u></u></p><p class="MsoNormal">We introduce a new perspective and a generalization of spectral networks for 4d N=2" style="position: relative;" tabindex="0" id="MathJax-Element-1-Frame" class="MathJax"&gt;<span lang="EN-US"></span>=2 theories of class S" style="position: relative;" tabindex="0" id="MathJax-Element-2-Frame" class="MathJax"&gt;<span lang="EN-US"></span> associated to Lie algebras g=An" style="position: relative;" tabindex="0" id="MathJax-Element-3-Frame" class="MathJax"&gt;<span style="font-family:"Cambria Math",serif">𝔤</span>=An, Dn" style="position: relative;" tabindex="0" id="MathJax-Element-4-Frame" class="MathJax"&gt;Dn, E6" style="position: relative;" tabindex="0" id="MathJax-Element-5-Frame" class="MathJax"&gt;E6, and E7" style="position: relative;" tabindex="0" id="MathJax-Element-6-Frame" class="MathJax"&gt;E7. Spectral networks directly compute the BPS spectra of 2d theories on surface defects coupled to the 4d theories. A Lie algebraic interpretation of these spectra emerges naturally from our construction, leading to a new description of 2d-4d wall-crossing phenomena. Our construction also provides an efficient framework for the study of BPS spectra of the 4d theories. In addition, we consider novel types of surface defects associated with minuscule representations of g" style="position: relative;" tabindex="0" id="MathJax-Element-7-Frame" class="MathJax"&gt;<span style="font-family:"Cambria Math",serif">𝔤</span>.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">** Truncated string:<u></u><u></u></p><p class="MsoNormal">We introduce a new perspective and a generalization of spectral networks for 4d N=2" style="position: relative;" tabindex="0" id="MathJax-Element-1-Frame" class="MathJax"&gt;<span lang="EN-US"></span>=2 theories of class S" style="position: relative;" tabindex="0" id="MathJax-Element-2-Frame" class="MathJax"&gt;<span lang="EN-US"></span> associated to Lie algebras g=An" style="position: relative;" tabindex="0" id="MathJax-Element-3-Frame" class="MathJax"&gt;<span style="font-family:"Cambria Math",serif">𝔤</span><u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span>David Cook<u></u><u></u></span></p><p class="MsoNormal"><span>Systems Librarian<u></u><u></u></span></p><p class="MsoNormal"><span>Prosentient Systems<u></u><u></u></span></p><p class="MsoNormal"><span>72/330 Wattle St<u></u><u></u></span></p><p class="MsoNormal"><span>Ultimo, NSW 2007<u></u><u></u></span></p><p class="MsoNormal"><span>Australia<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>Office: 02 9212 0899<u></u><u></u></span></p><p class="MsoNormal"><span>Direct: 02 8005 0595<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p></div></div><br>______________________________<wbr>_________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org">Koha-devel@lists.koha-<wbr>community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" target="_blank">http://lists.koha-community.<wbr>org/cgi-bin/mailman/listinfo/<wbr>koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.<wbr>org/</a><br></blockquote></div><br></div>