This patch enables utf-8 support and clean up build warnings about 
char/unsigned char conversino.

James 2014.

diff -ur yaf-splash-1.02/yaf-splash.c yaf-splash-1.02-new/yaf-splash.c
--- yaf-splash-1.02/yaf-splash.c	2003-02-23 07:25:39.000000000 +0700
+++ yaf-splash-1.02-new/yaf-splash.c	2014-04-29 12:10:29.400082309 +0700
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <time.h>
+#include <alloca.h>
 
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
@@ -217,6 +218,46 @@
   -margin                       Set the margin size (default: 0).\n\n");
 }
 
+/* Convert utf8 string to ucs2 string (XChar2b)
+ * This function is from here:
+ * xopendisplay.hilltopia.ca/2009/Mar/Xlib-tutorial-part-8----a-different-way-to-reach-wide-characters.html
+ */
+int utf8toXChar2b(XChar2b *output_r, int outsize, const char *input, int inlen){
+	int j, k;
+	for(j =0, k=0; j < inlen && k < outsize; j ++){
+		unsigned char c = input[j];
+		if (c < 128)  {
+			output_r[k].byte1 = 0;
+			output_r[k].byte2 = c; 
+			k++;
+		} else if (c < 0xC0) {
+			/* we're inside a character we don't know  */
+			continue;
+		} else switch(c&0xF0){
+		case 0xC0: case 0xD0: /* two bytes 5+6 = 11 bits */
+			if (inlen < j+1){ return k; }
+			output_r[k].byte1 = (c&0x1C) >> 2;
+			j++;
+			output_r[k].byte2 = ((c&0x3) << 6) + (input[j]&0x3F);
+			k++;
+			break;
+		case 0xE0: /* three bytes 4+6+6 = 16 bits */ 
+			if (inlen < j+2){ return k; }
+			j++;
+			output_r[k].byte1 = ((c&0xF) << 4) + ((input[j]&0x3C) >> 2);
+			c = input[j];
+			j++;
+			output_r[k].byte2 = ((c&0x3) << 6) + (input[j]&0x3F);
+			k++;
+			break;
+		case 0xFF:
+			/* the character uses more than 16 bits */
+			continue;
+		}
+	}
+	return k;
+}
+
 static int
 splash_ehandler (Display *display, XErrorEvent *error)
 {
@@ -427,6 +468,12 @@
 draw_word (draw_struct *state, const char *word, int len,
            int x, int y, int w, int h)
 {
+  char *word2;
+  int  word2len;
+  
+  word2 = alloca(len*2); /* at most 2 times the size */
+  word2len = utf8toXChar2b ((XChar2b *) word2, len, word, len);
+  
   int xshift, yshift;
   x += state->outline;
 
@@ -436,24 +483,24 @@
 	{       
 	  for (yshift = -1; yshift < 2; yshift += 2)
 	    {		  
-	      XDrawString(state->display, state->outline_pix,
+	      XDrawString16(state->display, state->outline_pix,
 			  state->pixmap_draw_gc,
 			  state->xoff + x + xshift * state->outline,
 			  state->yoff + y + state->font->ascent + 
 			  yshift * state->outline,
-			  word, len);
+			  (XChar2b *) word2, word2len);
 	    }
 	}
-       XDrawString (state->display, state->outline_pix, state->pixmap_draw_gc,
+       XDrawString16 (state->display, state->outline_pix, state->pixmap_draw_gc,
 	       state->xoff + x,
 	       state->yoff + y + state->font->ascent,
-	       (char *) word, len);    
+	       (XChar2b *) word2, word2len);    
     }
   
-  XDrawString (state->display, state->text_pix, state->pixmap_draw_gc,
+  XDrawString16 (state->display, state->text_pix, state->pixmap_draw_gc,
 	       state->xoff + x,
 	       state->yoff + y + state->font->ascent,
-	       (char *) word, len);
+	       (XChar2b *) word2, word2len);
 }
 
 
@@ -538,7 +585,7 @@
     }  
   else
     /* Set up draw_state->max_x, draw_state->max_y, the text block size */
-    iterate_words (draw_state, message, 
+    iterate_words (draw_state, (unsigned char*) message, 
 		   xgwa.width - (draw_state->margin * 2), count_word);
 
   
@@ -591,7 +638,7 @@
         }
 
       if (start != string)
-        mapper (state, start, string-start, x, y, word_w, line_height);
+        mapper (state, (char *) start, string-start, x, y, word_w, line_height);
 
       if (*string == '\n' || *string == 0)
         {
@@ -781,7 +828,7 @@
 			state->pixmap_erase_gc, 0, 0,
 			state->width, state->height);
       
-      iterate_words (state, message, state->width - (state->margin * 2), draw_word);
+      iterate_words (state, (unsigned char *) message, state->width - (state->margin * 2), draw_word);
       if (state->mirror_p)
 	mirror(state);
     }

