neurolabs / henplus

HenPlus is a SQL shell that can handle multiple sessions in parallel. The commandline interface with the usual history functions features TAB-completion for commands, tables and columns. Database connect via JDBC.
GNU General Public License v2.0
97 stars 51 forks source link

Unicode input support #30

Open googol4u opened 13 years ago

googol4u commented 13 years ago

Hi, Guys,

Thanks you for your great efforts to develop this tools. It makes remote management of databases possible.

However, some times we need to input Chinese to make some queries. It seems that henplus can not process Unicode characters correctly.

We use set-var to do the test. Hen*Plus> set-var HELLO 你好

then we read the 'setting' file in .henplus folder, it turns out to be:

HELLO=\u00E4\u00BD\u00A0\u00E5\u00A5\u00BD

actually, there are two characters that we have just inputed. the correct setting should be:

HELLO=\u4f60\u597d

seems that the inputed unicode charaters have been converted into byte array.

Any work around for this issue?

evgeny-gridasov commented 11 years ago

Hi I came across this issue like a couple of years ago and the workaround is in patching java readline library. It is a dirty hack but this is what works for me:

diff -Naur ./src/native/org_gnu_readline_Readline.c ../../libreadline-java-0.8.0/src/native/org_gnu_readline_Readline.c
--- ./src/native/org_gnu_readline_Readline.c    2003-01-07 20:14:35.000000000 +1000
+++ ../../libreadline-java-0.8.0/src/native/org_gnu_readline_Readline.c 2010-07-28 16:20:37.433083185 +1000
@@ -576,6 +576,8 @@
       return NULL;
   }

+  strcpy(buffer, utf8); return buffer;
+
   for (i=0,pin=utf8,pout=buffer; i<bufLength && *pin; i++,pin++,pout++) {
     current = *pin;
     if (current >= 0xE0) {                   /* we support only two-byte utf8 */
@@ -613,6 +615,8 @@
       return NULL;
   }

+  strcpy(buffer, ucs); return buffer;
+
   for (i=0,pin=ucs,pout=buffer; i<bufLength && *pin; i++,pin++,pout++) {
     current = *pin;
     if (current < 0x80)                      /* one-byte utf8                 */