tbl_change.php currently contains the following note:
// We don't want binary data to be destroyed
// Note: from the MySQL manual: "BINARY doesn't affect how the column is
// stored or retrieved" so it does not mean that the contents is
// binary
The problem is that binary fields are byte arrays rather than strings. Using binary fields instead of textual fields is a bad practicle because there is high chance that the data will be displayed incorrectly or data loss will occur.
There is no problem for SBCS (single byte character set) encodings because the byte-to-character mapping is a 1-to-1 mapping. MBCS (multi byte character set) encodings on the other hand can map some characters to a byte squence longer than one byte. The data loss can occur (at a very high probability with MBCS encodings) because proper decoder implementations has to filter out invalid byte sequences and when the data is converted back to a byte array, these invalid byte sequences are lost.
I usually use binary fields to store password hashes and small image files.
This problem not only affects East Asian languages but UTF-8 as well. And because UTF-8 is widely used by now some solution is necessary.
A very obvious solution is to modify the user interface to edit binary fields in hexadecimal.
Note that phpMyAdmin already has support for exoprting binary fields in hexadecimal and that is the default settings.
I believe that binary fields are intended to store binary (non-textual) data and as such they are better to be edited in hexadecimal.
I suggest to make this behavior default.
And this would render $cfg['ProtectBinary'] unnecessary so removing $cfg['ProtectBinary'] should be considered as well.
Hi Marc,
I'm having a little trouble understanding this requirement. I will tell how I understood it. Since editing binary fields like strings is bad practice we should avoid editing/inserting strings and then convert to hexadecimal. Rather we should directly input as hexadecimal values. So we need to implement a validation of hexadecimal. Am I right ?
Viduranga,
you are right.
Implemented with https://github.com/phpmyadmin/phpmyadmin/commit/02c4e352c56dde6ce6ea4e11656aec81e93eeb04
Last edit: Isaac Bennetch 2014-05-21