]> git.webhop.me Git - msgbox.git/commitdiff
msgbox: add utf8_to_latin1 encoding inspired from Neutrino/Zapittools ;) - by GetAwa...
authorJacek Jendrzej <crashdvb@googlemail.com>
Mon, 22 Sep 2014 14:27:55 +0000 (16:27 +0200)
committerJacek Jendrzej <crashdvb@googlemail.com>
Mon, 22 Sep 2014 14:27:55 +0000 (16:27 +0200)
gfx.c
msgbox.c
text.c

diff --git a/gfx.c b/gfx.c
index f724b0a6dca925f828d9baa204fbc451e144fba2..d49bb90ae01c08f2dba1b3ba4d740c2474db10c1 100644 (file)
--- a/gfx.c
+++ b/gfx.c
@@ -10,7 +10,7 @@ void RenderBox(int _sx, int _sy, int _ex, int _ey, int rad, int col)
                
        if (dxx<0) 
        {
-               printf("[shellexec] RenderBox called with dx < 0 (%d)\n", dxx);
+               printf("[msgbox] RenderBox called with dx < 0 (%d)\n", dxx);
                dxx=0;
        }
 
index 2543b3a25120315f1fbac6b59cd432fc08760981..b42a22fe796d0c4a63aeda9f77ee416c021171d1 100644 (file)
--- a/msgbox.c
+++ b/msgbox.c
@@ -8,7 +8,7 @@
 #include "gfx.h"
 #include "txtform.h" 
 
-#define M_VERSION 1.12
+#define M_VERSION 1.18
 
 #define NCF_FILE       "/var/tuxbox/config/neutrino.conf"
 #define HDF_FILE       "/tmp/.msgbox_hidden"
@@ -216,7 +216,8 @@ char *pt1=strdup(sptr),*pt2,*pt3;
 }
 
 static int yo=80,dy;
-static int psx, psy, pxw, pyw, myo=0, buttx=80, butty=30, buttdx=20, buttdy=10, buttsize=0, buttxstart=0, buttystart=0;
+int psx;
+static int psy, pxw, pyw, myo=0, buttx=80, butty=30, buttdx=20, buttdy=10, buttsize=0, buttxstart=0, buttystart=0;
 
 int show_txt(int buttonly)
 {
diff --git a/text.c b/text.c
index 6a64b6fe609c8e00e3682acc3536bef21ca9cce0..5d96ae5482e1482f1619ffa055e8c8eeee0755cc 100644 (file)
--- a/text.c
+++ b/text.c
@@ -184,7 +184,7 @@ void CatchTabs(char *text)
 /******************************************************************************
  * RenderString
  ******************************************************************************/
-
+extern int psx;
 int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int size, int color)
 {
        int stringlen = 0, _ex = 0, charwidth = 0,found = 0;
@@ -256,6 +256,7 @@ int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int s
                                                        if(sscanf(rptr+1,"%4d",&i)==1)
                                                        {
                                                                rptr+=4;
+                                                               sx = psx + 10 + i;
                                                                _sx=i;
                                                        }
                                                break;
@@ -264,7 +265,51 @@ int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int s
                        }
                        else
                        {
-                               if((charwidth = RenderChar(*rptr, _sx, _sy, _ex, varcolor)) == -1) return _sx; /* string > maxwidth */
+                               int uml = 0;
+                               switch(*rptr)    /* skip Umlauts */
+                               {
+                                       case '\xc4':
+                                       case '\xd6':
+                                       case '\xdc':
+                                       case '\xe4':
+                                       case '\xf6':
+                                       case '\xfc':
+                                       case '\xdf': uml=1; break;
+                               }
+                               if (uml == 0)
+                               {
+                                       // UTF8_to_Latin1 encoding
+                                       if (((*rptr) & 0xf0) == 0xf0)      /* skip (can't be encoded in Latin1) */
+                                       {
+                                               rptr++;
+                                               if ((*rptr) == 0)
+                                                       *rptr='\x3f'; // ? question mark
+                                               rptr++;
+                                               if ((*rptr) == 0)
+                                                       *rptr='\x3f';
+                                               rptr++;
+                                               if ((*rptr) == 0)
+                                                       *rptr='\x3f';
+                                       }
+                                       else if (((*rptr) & 0xe0) == 0xe0) /* skip (can't be encoded in Latin1) */
+                                       {
+                                               rptr++;
+                                               if ((*rptr) == 0)
+                                                       *rptr='\x3f';
+                                               rptr++;
+                                               if ((*rptr) == 0)
+                                                       *rptr='\x3f';
+                                       }
+                                       else if (((*rptr) & 0xc0) == 0xc0)
+                                       {
+                                               char c = (((*rptr) & 3) << 6);
+                                               rptr++;
+                                               if ((*rptr) == 0)
+                                                       *rptr='\x3f';
+                                               *rptr = (c | ((*rptr) & 0x3f));
+                                       }
+                               }
+                               if((charwidth = RenderChar(*rptr, _sx, _sy, _ex, varcolor)) == -1) return _sx; /* string > maxwidth */
                                _sx += charwidth;
                        }
                        rptr++;