[liblouis-liblouisxml] [liblouis] r570 committed - updating lou_translate to accept and display Unicode characters proper...

  • From: liblouis@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Mon, 16 Apr 2012 22:22:10 +0000

Revision: 570
Author:   john.boyer@xxxxxxxxxxxxxxxxx
Date:     Mon Apr 16 15:21:47 2012
Log: updating lou_translate to accept and display Unicode characters properly
http://code.google.com/p/liblouis/source/detail?r=570

Modified:
 /trunk/liblouis/compileTranslationTable.c
 /trunk/tools/lou_translate.c

=======================================
--- /trunk/liblouis/compileTranslationTable.c   Wed Mar 28 15:24:10 2012
+++ /trunk/liblouis/compileTranslationTable.c   Mon Apr 16 15:21:47 2012
@@ -393,7 +393,7 @@
   scratchBuf[bufPos++] = '\'';
   for (charPos = 0; charPos < length; charPos++)
     {
-      if (chars[charPos] > 32 && chars[charPos] < 127)
+      if (chars[charPos] >= 32 && chars[charPos] < 127)
        scratchBuf[bufPos++] = (char) chars[charPos];
       else
        {
=======================================
--- /trunk/tools/lou_translate.c        Tue Nov 10 04:55:27 2009
+++ /trunk/tools/lou_translate.c        Mon Apr 16 15:21:47 2012
@@ -32,10 +32,11 @@
 #include <stdlib.h>
 #include <getopt.h>
 #include "liblouis.h"
+#include "louis.h"
 #include "progname.h"
 #include "version-etc.h"

-#define BUFSIZE 2048
+#define BUFSIZE MAXSTRING - 4

 static int forward_flag = 0;
 static int backward_flag = 0;
@@ -57,37 +58,37 @@
 static void
 translate_input (int forward_translation, char *table_name)
 {
+  char charbuf[BUFSIZE];
+  char *outputbuf;
   widechar inbuf[BUFSIZE];
   widechar transbuf[BUFSIZE];
   int inlen;
   int translen;
-  int ch = 0;
   int k;
+  int ch = 0;
   int result;
-
   while (1)
     {
       translen = BUFSIZE;
-      inlen = 0;
-      while ((ch = getchar ()) != '\n' && inlen < BUFSIZE)
-       inbuf[inlen++] = ch;
+      k = 0;
+      while ((ch = getchar ()) != '\n' && ch != EOF && k < BUFSIZE)
+       charbuf[k++] = ch;
       if (ch == EOF)
        break;
-      inbuf[inlen] = 0;
+      charbuf[k] = 0;
+      inlen = extParseChars (charbuf, inbuf);
       if (forward_translation)
-       {
          result = lou_translateString (table_name, inbuf, &inlen,
                                      transbuf, &translen, NULL, NULL, 0);
-       }
       else
        result = lou_backTranslateString (table_name, inbuf, &inlen,
                                          transbuf, &translen, NULL, NULL, 0);
       if (!result)
        break;
-      transbuf[translen] = 0;
-      for (k = 0; k < translen; k++)
-       printf ("%c", transbuf[k]);
-      printf ("\n");
+      outputbuf = showString (transbuf, translen);
+      k = strlen (outputbuf) - 1;
+      outputbuf[k] = 0;
+      printf ("%s\n", &outputbuf[1]);
     }
   lou_free ();
 }
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouis] r570 committed - updating lou_translate to accept and display Unicode characters proper... - liblouis