<div dir="ltr">Yes it's a known issue, see bug 15794.<div>We already discuss this a bit on bug 11944 as well.<div>I know PTFS-E guys are using utf8mb4 already.</div><div>It should not be hard to make this move, at least for new installs.</div><div><br></div><div>Cheers,</div><div>Jonathan<br><br><div class="gmail_quote"><div dir="ltr">On Fri, 24 Mar 2017 at 03:08 David Cook <<a href="mailto:dcook@prosentient.com.au">dcook@prosentient.com.au</a>> wrote:<br></div><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" class="gmail_msg"><div class="m_7406913238636906749WordSection1 gmail_msg"><p class="MsoNormal gmail_msg">Hi all,<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">However, I eventually found <a href="https://bugs.mysql.com/bug.php?id=53005" class="gmail_msg" target="_blank">https://bugs.mysql.com/bug.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" class="gmail_msg" target="_blank">https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8.html</a>). That tends to be fine in most cases, but <span style="font-family:"Cambria Math",serif" class="gmail_msg">𝔤 </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" class="gmail_msg" target="_blank">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</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" class="gmail_msg" target="_blank">https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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" class="gmail_msg"></span>=2 theories of class S" style="position: relative;" tabindex="0" id="MathJax-Element-2-Frame" class="MathJax"&gt;<span lang="EN-US" class="gmail_msg"></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" class="gmail_msg">𝔤</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" class="gmail_msg">𝔤</span>.' where biblionumber = 50314;<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">Query OK, 0 rows affected, 1 warning (0.00 sec)<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">Rows matched: 1  Changed: 0  Warnings: 1<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">+---------+------+--------------------------------------------------------------------------------+<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">| Level   | Code | Message                                                                        |<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">+---------+------+--------------------------------------------------------------------------------+<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">| Warning | 1366 | Incorrect string value: '\xF0\x9D\x94\xA4=A...' for column 'abstract' at row 1 |<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">+---------+------+--------------------------------------------------------------------------------+<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">1 row in set (0.01 sec)<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">With DBI, it’s harder: <a href="http://stackoverflow.com/questions/7946655/dbi-perl-logging-mysql-warnings" class="gmail_msg" target="_blank">http://stackoverflow.com/questions/7946655/dbi-perl-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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">So this seems like an edgecase… it’s some wonky data (albeit valid UTF8 data) in an otherwise English record. <u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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 class="gmail_msg">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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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 class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">I’m at the end of my Friday work day, so I’m going to leave it there, but food for thought!<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">*Aforementioned strange data:<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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" class="gmail_msg"></span>=2 theories of class S" style="position: relative;" tabindex="0" id="MathJax-Element-2-Frame" class="MathJax"&gt;<span lang="EN-US" class="gmail_msg"></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" class="gmail_msg">𝔤</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" class="gmail_msg">𝔤</span>.<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">** Truncated string:<u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg">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" class="gmail_msg"></span>=2 theories of class S" style="position: relative;" tabindex="0" id="MathJax-Element-2-Frame" class="MathJax"&gt;<span lang="EN-US" class="gmail_msg"></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" class="gmail_msg">𝔤</span><u class="gmail_msg"></u><u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">David Cook<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">Systems Librarian<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">Prosentient Systems<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">72/330 Wattle St<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">Ultimo, NSW 2007<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">Australia<u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">Office: <a href="tel:02%2092%2012%2008%2099" value="+33292120899" class="gmail_msg" target="_blank">02 9212 0899</a><u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><span class="gmail_msg">Direct: <a href="tel:02%2080%2005%2005%2095" value="+33280050595" class="gmail_msg" target="_blank">02 8005 0595</a><u class="gmail_msg"></u><u class="gmail_msg"></u></span></p><p class="MsoNormal gmail_msg"><u class="gmail_msg"></u> <u class="gmail_msg"></u></p></div></div>_______________________________________________<br class="gmail_msg">
Koha-devel mailing list<br class="gmail_msg">
<a href="mailto:Koha-devel@lists.koha-community.org" class="gmail_msg" target="_blank">Koha-devel@lists.koha-community.org</a><br class="gmail_msg">
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br class="gmail_msg">
website : <a href="http://www.koha-community.org/" rel="noreferrer" class="gmail_msg" target="_blank">http://www.koha-community.org/</a><br class="gmail_msg">
git : <a href="http://git.koha-community.org/" rel="noreferrer" class="gmail_msg" target="_blank">http://git.koha-community.org/</a><br class="gmail_msg">
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" class="gmail_msg" target="_blank">http://bugs.koha-community.org/</a></blockquote></div></div></div></div>