Index: aim.c
===================================================================
--- aim.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
+++ aim.c	(revision 9854278fd0ac47586e8157e1efa798dd2583d81e)
@@ -948,5 +948,5 @@
   
   if (modname) {
-    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
+    if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
       /* perror("memrequest: malloc"); */
       return -1;
@@ -954,5 +954,5 @@
     sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname);
   } else {
-    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
+    if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
       /* perror("memrequest: malloc"); */
       return -1;
@@ -964,5 +964,5 @@
     if (!modname) {
       /* perror("memrequest: stat"); */
-      owl_free(filename);
+      free(filename);
       return -1;
     }
@@ -986,5 +986,5 @@
     int i;
     
-    owl_free(filename); /* not needed */
+    free(filename); /* not needed */
     owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
     i = 8;
@@ -993,5 +993,5 @@
     }
     
-    if (!(buf = owl_malloc(i))) {
+    if (!(buf = malloc(i))) {
       return -1;
     }
@@ -1017,6 +1017,6 @@
     *buflenret = i;
   } else {
-    if (!(buf = owl_malloc(len))) {
-      owl_free(filename);
+    if (!(buf = malloc(len))) {
+      free(filename);
       return -1;
     }
@@ -1024,15 +1024,15 @@
     if (!(f = fopen(filename, "r"))) {
       /* perror("memrequest: fopen"); */
-      owl_free(filename);
-      owl_free(buf);
+      free(filename);
+      free(buf);
       return -1;
     }
     
-    owl_free(filename);
+    free(filename);
     
     if (fseek(f, offset, SEEK_SET) == -1) {
       /* perror("memrequest: fseek"); */
       fclose(f);
-      owl_free(buf);
+      free(buf);
       return -1;
     }
@@ -1041,5 +1041,5 @@
       /* perror("memrequest: fread"); */
       fclose(f);
-      owl_free(buf);
+      free(buf);
       return -1;
     }
@@ -1076,5 +1076,5 @@
   if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) {
     aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
-    owl_free(buf);
+    free(buf);
   } else {
     owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname);
@@ -1342,10 +1342,10 @@
       int z;
       
-      newbuf = owl_malloc(i+1);
+      newbuf = malloc(i+1);
       for (z = 0; z < i; z++)
 	newbuf[z] = (z % 10)+0x30;
       newbuf[i] = '\0';
       /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */
-      owl_free(newbuf);
+      free(newbuf);
     }
   } else if (strstr(tmpstr, "seticqstatus")) {
Index: cmd.c
===================================================================
--- cmd.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
+++ cmd.c	(revision 6922eddf979a8bdbf46a21cad138b787a7719f46)
@@ -74,5 +74,5 @@
   owl_cmd *cmd;
 
-  tmpbuff=owl_strdup(cmdbuff);
+  tmpbuff=strdup(cmdbuff);
   argv=owl_parseline(tmpbuff, &argc);
   if (argc < 0) {
Index: configure.in
===================================================================
--- configure.in	(revision 762512d45127ed90801a7899ed693a54014067be)
+++ configure.in	(revision 18e28a410181648e32a57fac7edf9942a364a49d)
@@ -12,6 +12,4 @@
 fi
 
-m4_include(/usr/share/aclocal/pkg.m4)
-dnl m4_include(pkg.m4)
 
 dnl Check for Athena
@@ -111,13 +109,4 @@
 LDFLAGS=${LDFLAGS}\ ${FOO}
 
-dnl Add CFLAGS and LDFLAGS for glib-2.0
-PKG_CHECK_MODULES(GLIB,glib-2.0)
-
-echo Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}
-CFLAGS=${CFLAGS}\ ${GLIB_CFLAGS}
-echo Adding glib-2.0 LDFLAGS ${GLIB_LIBS}
-LDFLAGS=${LDFLAGS}\ ${GLIB_LIBS}
-
-
 dnl Checks for typedefs, structures, and compiler characteristics.
 
Index: fmtext.c
===================================================================
--- fmtext.c	(revision 5376a95c0ff753a89c734d966bf048447b90f3db)
+++ fmtext.c	(revision fa3290d0243ae8fb36df1f09bbe9bc943d1efc06)
@@ -8,11 +8,14 @@
 void owl_fmtext_init_null(owl_fmtext *f)
 {
-  f->textlen = 0;
-  f->bufflen = 5;
-  f->textbuff = owl_malloc(5);
-  f->textbuff[0] = 0;
-  f->default_attrs = OWL_FMTEXT_ATTR_NONE;
-  f->default_fgcolor = OWL_COLOR_DEFAULT;
-  f->default_fgcolor = OWL_COLOR_DEFAULT;
+  f->textlen=0;
+  f->bufflen=5;
+  f->textbuff=owl_malloc(5);
+  f->fmbuff=owl_malloc(5);
+  f->fgcolorbuff=owl_malloc(5 * sizeof(short));
+  f->bgcolorbuff=owl_malloc(5 * sizeof(short));
+  f->textbuff[0]=0;
+  f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE;
+  f->fgcolorbuff[0]=OWL_COLOR_DEFAULT;
+  f->bgcolorbuff[0]=OWL_COLOR_DEFAULT;
 }
 
@@ -21,9 +24,50 @@
 void owl_fmtext_clear(owl_fmtext *f)
 {
-  f->textlen = 0;
-  f->textbuff[0] = 0;
-  f->default_attrs = OWL_FMTEXT_ATTR_NONE;
-  f->default_fgcolor = OWL_COLOR_DEFAULT;
-  f->default_fgcolor = OWL_COLOR_DEFAULT;
+    f->textlen = 0;
+    f->textbuff[0] = 0;
+    f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE;
+    f->fgcolorbuff[0]=OWL_COLOR_DEFAULT;
+    f->bgcolorbuff[0]=OWL_COLOR_DEFAULT;
+}
+
+/* Internal function.  Set the attribute 'attr' from index 'first' to
+ * index 'last'
+ */
+void _owl_fmtext_set_attr(owl_fmtext *f, int attr, int first, int last)
+{
+  int i;
+  for (i=first; i<=last; i++) {
+    f->fmbuff[i]=(unsigned char) attr;
+  }
+}
+
+/* Internal function.  Add the attribute 'attr' to the existing
+ * attributes from index 'first' to index 'last'
+ */
+void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last)
+{
+  int i;
+  for (i=first; i<=last; i++) {
+    f->fmbuff[i]|=(unsigned char) attr;
+  }
+}
+
+/* Internal function.  Set the color to be 'color' from index 'first'
+ * to index 'last
+ */
+void _owl_fmtext_set_fgcolor(owl_fmtext *f, int color, int first, int last)
+{
+  int i;
+  for (i=first; i<=last; i++) {
+    f->fgcolorbuff[i]=(short)color;
+  }
+}
+
+void _owl_fmtext_set_bgcolor(owl_fmtext *f, int color, int first, int last)
+{
+  int i;
+  for (i=first; i<=last; i++) {
+    f->bgcolorbuff[i]=(short)color;
+  }
 }
 
@@ -31,54 +75,25 @@
 {
     if(newlen + 1 > f->bufflen) {
-      f->textbuff = owl_realloc(f->textbuff, newlen + 1);
+      f->textbuff=owl_realloc(f->textbuff, newlen+1);
+      f->fmbuff=owl_realloc(f->fmbuff, newlen+1);
+      f->fgcolorbuff=owl_realloc(f->fgcolorbuff, (newlen+1) * sizeof(short));
+      f->bgcolorbuff=owl_realloc(f->bgcolorbuff, (newlen+1) * sizeof(short));
       f->bufflen = newlen+1;
   }
 }
 
-int _owl_fmtext_is_format_char(gunichar c) /*noproto*/
-{
-  if ((c & ~OWL_FMTEXT_UC_ATTR_MASK) == OWL_FMTEXT_UC_ATTR) return 1;
-  if ((c & ~(OWL_FMTEXT_UC_ALLCOLOR_MASK)) == OWL_FMTEXT_UC_COLOR_BASE) return 1;
-  return 0;
-}
 /* append text to the end of 'f' with attribute 'attr' and color
  * 'color'
  */
-void owl_fmtext_append_attr(owl_fmtext *f, char *text, char attr, short fgcolor, short bgcolor)
-{
-  char attrbuff[6];
-  int newlen, a = 0, fg = 0, bg = 0;
-  
-  if (attr != OWL_FMTEXT_ATTR_NONE) a=1;
-  if (fgcolor != OWL_COLOR_DEFAULT) fg=1;
-  if (bgcolor != OWL_COLOR_DEFAULT) bg=1;
-
-  /* Plane-16 characters in UTF-8 are 4 bytes long. */
-  newlen = strlen(f->textbuff) + strlen(text) + (8 * (a + fg + bg));
+void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int fgcolor, int bgcolor)
+{
+  int newlen;
+  newlen=strlen(f->textbuff)+strlen(text);
   _owl_fmtext_realloc(f, newlen);
-
-  /* Set attributes */
-  if (a) {
-    memset(attrbuff,0,6);
-    g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff);
-    strcat(f->textbuff, attrbuff);      
-  }
-  if (fg) {
-    memset(attrbuff,0,6);
-    g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff);
-    strcat(f->textbuff, attrbuff);      
-  }
-  if (bg) {
-    memset(attrbuff,0,6);
-    g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff);
-    strcat(f->textbuff, attrbuff);      
-  }
   
   strcat(f->textbuff, text);
-
-  /* Reset attributes */
-  if (bg) strcat(f->textbuff, OWL_FMTEXT_UTF8_BGDEFAULT);
-  if (fg) strcat(f->textbuff, OWL_FMTEXT_UTF8_FGDEFAULT);
-  if (a)  strcat(f->textbuff, OWL_FMTEXT_UTF8_ATTR_NONE);
+  _owl_fmtext_set_attr(f, attr, f->textlen, newlen);
+  _owl_fmtext_set_fgcolor(f, fgcolor, f->textlen, newlen);
+  _owl_fmtext_set_bgcolor(f, bgcolor, f->textlen, newlen);
   f->textlen=newlen;
 }
@@ -114,101 +129,58 @@
 }
 
-/* Add the attribute 'attr' to the default atts for the text in 'f' */
-void owl_fmtext_addattr(owl_fmtext *f, char attr)
+/* Add the attribute 'attr' to all text in 'f' */
+void owl_fmtext_addattr(owl_fmtext *f, int attr)
 {
   /* add the attribute to all text */
-  f->default_attrs |= attr;
-}
-
-/* Set the default foreground color for this fmtext to 'color'.
- * Only affects text that is colored default.
+  int i, j;
+
+  j=f->textlen;
+  for (i=0; i<j; i++) {
+    f->fmbuff[i] |= attr;
+  }
+}
+
+/* Anywhere the color is NOT ALREDY SET, set the color to 'color'.
+ * Other colors are left unchanged
  */
 void owl_fmtext_colorize(owl_fmtext *f, int color)
 {
-  f->default_fgcolor = color;
-}
-
-/* Set the default foreground color for this fmtext to 'color'.
- * Only affects text that is colored default.
- */
+  /* everywhere the fgcolor is OWL_COLOR_DEFAULT, change it to be 'color' */
+  int i, j;
+
+  j=f->textlen;
+  for(i=0; i<j; i++) {
+    if (f->fgcolorbuff[i]==OWL_COLOR_DEFAULT) f->fgcolorbuff[i] = (short)color;
+  }
+}
+
 void owl_fmtext_colorizebg(owl_fmtext *f, int color)
 {
-  f->default_bgcolor = color;
-}
-
-/* Internal function. Parse attrbute character. */
-void _owl_fmtext_update_attributes(gunichar c, char *attr, short *fgcolor, short *bgcolor) /*noproto*/
-{
-  if ((c & OWL_FMTEXT_UC_ATTR) == OWL_FMTEXT_UC_ATTR) {
-    *attr = c & OWL_FMTEXT_UC_ATTR_MASK;
-  }
-  else if ((c & OWL_FMTEXT_UC_FGCOLOR) == OWL_FMTEXT_UC_FGCOLOR) {
-    *fgcolor = (c == OWL_FMTEXT_UC_FGDEFAULT
-		? OWL_COLOR_DEFAULT
-		: c & OWL_FMTEXT_UC_COLOR_MASK);
-  }
-  else if ((c & OWL_FMTEXT_UC_BGCOLOR) == OWL_FMTEXT_UC_BGCOLOR) {
-    *bgcolor = (c == OWL_FMTEXT_UC_BGDEFAULT
-		? OWL_COLOR_DEFAULT
-		: c & OWL_FMTEXT_UC_COLOR_MASK);
-  }
-}
-
-/* Internal function. Scan for attribute characters. */
-void _owl_fmtext_scan_attributes(owl_fmtext *f, int start, char *attr, short *fgcolor, short *bgcolor) /*noproto*/
-{
-  char *p;
-  p = strchr(f->textbuff, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-  while (p && p < f->textbuff + start) {
-    _owl_fmtext_update_attributes(g_utf8_get_char(p), attr, fgcolor, bgcolor);
-    p = strchr(p+1, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-  }
-}  
+  /* everywhere the bgcolor is OWL_COLOR_DEFAULT, change it to be 'color' */
+  int i, j;
+
+  j=f->textlen;
+  for(i=0; i<j; i++) {
+    if (f->bgcolorbuff[i]==OWL_COLOR_DEFAULT) f->bgcolorbuff[i] = (short)color;
+  }
+}
 
 /* Internal function.  Append text from 'in' between index 'start' and
  * 'stop' to the end of 'f'
  */
-void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop) /*noproto*/
-{
-  char attrbuff[6];
-  int newlen, a = 0, fg = 0, bg = 0;
-  char attr = 0;
-  short fgcolor = OWL_COLOR_DEFAULT;
-  short bgcolor = OWL_COLOR_DEFAULT;
-
-  _owl_fmtext_scan_attributes(in, start, &attr, &fgcolor, &bgcolor);
-  if (attr != OWL_FMTEXT_ATTR_NONE) a=1;
-  if (fgcolor != OWL_COLOR_DEFAULT) fg=1;
-  if (bgcolor != OWL_COLOR_DEFAULT) bg=1;
-
-  /* We will reset to defaults after appending the text. We may need
-     to set initial attributes. */
-  newlen=strlen(f->textbuff)+(stop-start+1) + (4 * (a + fg + bg)) + 12;
+void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop)
+{
+  int newlen, i;
+
+  newlen=strlen(f->textbuff)+(stop-start+1);
   _owl_fmtext_realloc(f, newlen);
 
-  if (a) {
-    memset(attrbuff,0,6);
-    g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff);
-    strcat(f->textbuff, attrbuff);      
-  }
-  if (fg) {
-    memset(attrbuff,0,6);
-    g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff);
-    strcat(f->textbuff, attrbuff);      
-  }
-  if (bg) {
-    memset(attrbuff,0,6);
-    g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff);
-    strcat(f->textbuff, attrbuff);      
-  }
-
   strncat(f->textbuff, in->textbuff+start, stop-start+1);
-
-  /* Reset attributes */
-  strcat(f->textbuff, OWL_FMTEXT_UTF8_BGDEFAULT);
-  strcat(f->textbuff, OWL_FMTEXT_UTF8_FGDEFAULT);
-  strcat(f->textbuff, OWL_FMTEXT_UTF8_ATTR_NONE);
-
   f->textbuff[newlen]='\0';
+  for (i=start; i<=stop; i++) {
+    f->fmbuff[f->textlen+(i-start)]=in->fmbuff[i];
+    f->fgcolorbuff[f->textlen+(i-start)]=in->fgcolorbuff[i];
+    f->bgcolorbuff[f->textlen+(i-start)]=in->bgcolorbuff[i];
+  }
   f->textlen=newlen;
 }
@@ -235,26 +207,15 @@
 char *owl_fmtext_print_plain(owl_fmtext *f)
 {
-  return owl_strip_format_chars(f->textbuff);
-}
-
-void _owl_fmtext_wattrset(WINDOW *w, int attrs) /*noproto*/
-{
-  wattrset(w, A_NORMAL);
-  if (attrs & OWL_FMTEXT_ATTR_BOLD) wattron(w, A_BOLD);
-  if (attrs & OWL_FMTEXT_ATTR_REVERSE) wattron(w, A_REVERSE);
-  if (attrs & OWL_FMTEXT_ATTR_UNDERLINE) wattron(w, A_UNDERLINE);
-}
+  return(owl_strdup(f->textbuff));
+}
+
 /* add the formatted text to the curses window 'w'.  The window 'w'
  * must already be initiatlized with curses
  */
-void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w, int do_search)
-{
-  /* char *tmpbuff; */
-  /* int position, trans1, trans2, trans3, len, lastsame; */
-  char *s, *p;
-  char attr;
-  short fg, bg;
-  int search_results, search_len;
-  
+void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w)
+{
+  char *tmpbuff;
+  int position, trans1, trans2, trans3, len, lastsame;
+
   if (w==NULL) {
     owl_function_debugmsg("Hit a null window in owl_fmtext_curs_waddstr.");
@@ -262,90 +223,51 @@
   }
 
-  search_results = (do_search
-		    ? owl_fmtext_search(f, owl_global_get_search_string(&g))
-		    : NULL);
-  if (search_results) search_len = strlen(owl_global_get_search_string(&g));
-  s = f->textbuff;
-  /* Set default attributes. */
-  attr = f->default_attrs;
-  fg = f->default_fgcolor;
-  bg = f->default_bgcolor;
-  _owl_fmtext_wattrset(w, attr);
-  if (owl_global_get_hascolors(&g)) {
-    short pair;
-    pair = owl_fmtext_get_colorpair(fg, bg);
-    if (pair != -1) {
-      wcolor_set(w,pair,NULL);
-    }
-  }
-
-  /* Find next possible format character. */
-  p = strchr(s, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-  while(p) {
-    if (_owl_fmtext_is_format_char(g_utf8_get_char(p))) {
-      /* Deal with all text from last insert to here. */
-      char tmp;
-   
-      tmp = p[0];
-      p[0] = '\0';
-      if (search_results) {
-	/* Search is active, so highlight search results. */
-	char tmp2, *ss;
-	ss = stristr(s, owl_global_get_search_string(&g));
-	while (ss) {
-	  /* Found search string, highlight it. */
-
-	  tmp2 = ss[0];
-	  ss[0] = '\0';
-	  waddstr(w, s);
-	  ss[0] = tmp2;
-
-	  _owl_fmtext_wattrset(w,attr ^ A_REVERSE);
-
-	  tmp2 = ss[search_len];
-	  ss[search_len] = '\0';
-	  waddstr(w, ss);
-	  ss[search_len] = tmp2;
-
-	  _owl_fmtext_wattrset(w,attr);
-
-	  s = ss + search_len;
-	  ss = stristr(s, owl_global_get_search_string(&g));
-	}
-      }
-      /* Deal with remaining part of string. */
-      waddstr(w, s);
-      p[0] = tmp;
-
-      /* Deal with new attributes. Initialize to defaults, then
-	 process all consecutive formatting characters. */
-      attr = f->default_attrs;
-      fg = f->default_fgcolor;
-      bg = f->default_bgcolor;
-      while (p && _owl_fmtext_is_format_char(g_utf8_get_char(p))) {
-	_owl_fmtext_update_attributes(g_utf8_get_char(p), &attr, &fg, &bg);
-	p = g_utf8_next_char(p);
-      }
-      _owl_fmtext_wattrset(w, attr | f->default_attrs);
-      if (owl_global_get_hascolors(&g)) {
-	if (fg == OWL_COLOR_DEFAULT) fg = f->default_fgcolor;
-	if (bg == OWL_COLOR_DEFAULT) bg = f->default_bgcolor;
-	short pair;
-	pair = owl_fmtext_get_colorpair(fg, bg);
-	if (pair != -1) {
-	  wcolor_set(w,pair,NULL);
-	}
-      }
-      /* Advance to next non-formatting character. */
-      s = p;
-      p = strchr(s, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-    }
-    else {
-      p = strchr(p+1, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-    }
-  }
-  if (s) {
-    waddstr(w, s);
-  }
+  tmpbuff=owl_malloc(f->textlen+10);
+
+  position=0;
+  len=f->textlen;
+  while (position<=len) {
+    /* find the last char with the current format and color */
+    trans1=owl_util_find_trans(f->fmbuff+position, len-position);
+    trans2=owl_util_find_trans_short(f->fgcolorbuff+position, len-position);
+    trans3=owl_util_find_trans_short(f->bgcolorbuff+position, len-position);
+
+    lastsame = (trans1 < trans2) ? trans1 : trans2;
+    lastsame = (lastsame < trans3) ? lastsame : trans3;
+    lastsame += position;
+
+    /* set the format */
+    wattrset(w, A_NORMAL);
+    if (f->fmbuff[position] & OWL_FMTEXT_ATTR_BOLD) {
+      wattron(w, A_BOLD);
+    }
+    if (f->fmbuff[position] & OWL_FMTEXT_ATTR_REVERSE) {
+      wattron(w, A_REVERSE);
+    }
+    if (f->fmbuff[position] & OWL_FMTEXT_ATTR_UNDERLINE) {
+      wattron(w, A_UNDERLINE);
+    }
+
+    /* set the color */
+    /* warning, this is sort of a hack */
+    if (owl_global_get_hascolors(&g)) {
+      short fg, bg, pair;
+      fg = f->fgcolorbuff[position];
+      bg = f->bgcolorbuff[position];
+
+      pair = owl_fmtext_get_colorpair(fg, bg);
+      if (pair != -1) {
+        wcolor_set(w,pair,NULL);
+      }
+    }
+
+    /* add the text */
+    strncpy(tmpbuff, f->textbuff + position, lastsame-position+1);
+    tmpbuff[lastsame-position+1]='\0';
+    waddstr(w, tmpbuff);
+
+    position=lastsame+1;
+  }
+  owl_free(tmpbuff);
 }
 
@@ -360,25 +282,26 @@
   
   /* find the starting line */
-  ptr1 = in->textbuff;
-  for (i = 0; i < aline; i++) {
-    ptr1 = strchr(ptr1, '\n');
-    if (!ptr1) return(-1);
-    ptr1++;
-  }
-  
+  ptr1=in->textbuff;
+  if (aline!=0) {
+    for (i=0; i<aline; i++) {
+      ptr1=strchr(ptr1, '\n');
+      if (!ptr1) return(-1);
+      ptr1++;
+    }
+  }
   /* ptr1 now holds the starting point */
 
   /* copy in the next 'lines' lines */
-  if (lines < 1) return(-1);
-
-  for (i = 0; i < lines; i++) {
-    offset = ptr1 - in->textbuff;
-    ptr2 = strchr(ptr1, '\n');
+  if (lines<1) return(-1);
+
+  for (i=0; i<lines; i++) {
+    offset=ptr1-in->textbuff;
+    ptr2=strchr(ptr1, '\n');
     if (!ptr2) {
-      _owl_fmtext_append_fmtext(out, in, offset, (in->textlen) - 1);
+      _owl_fmtext_append_fmtext(out, in, offset, (in->textlen)-1);
       return(-1);
     }
-    _owl_fmtext_append_fmtext(out, in, offset, (ptr2 - ptr1) + offset);
-    ptr1 = ptr2 + 1;
+    _owl_fmtext_append_fmtext(out, in, offset, (ptr2-ptr1)+offset);
+    ptr1=ptr2+1;
   }
   return(0);
@@ -392,62 +315,43 @@
 void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out)
 {
-  char *ptr_s, *ptr_e, *ptr_c, *last;
-  int col, st, padding, chwidth;
+  char *ptr1, *ptr2, *last;
+  int len, offset;
 
   last=in->textbuff+in->textlen-1;
-  ptr_s=in->textbuff;
-  while (ptr_s <= last) {
-    ptr_e=strchr(ptr_s, '\n');
-    if (!ptr_e) {
+  ptr1=in->textbuff;
+  while (ptr1<=last) {
+    ptr2=strchr(ptr1, '\n');
+    if (!ptr2) {
       /* but this shouldn't happen if we end in a \n */
       break;
     }
     
-    if (ptr_e == ptr_s) {
+    if (ptr2==ptr1) {
       owl_fmtext_append_normal(out, "\n");
-      ++ptr_s;
+      ptr1++;
       continue;
     }
 
-    col = 0;
-    st = 0;
-    padding = 0;
-    ptr_c = ptr_s;
-    while(col <= bcol && ptr_c < ptr_e) {
-      gunichar c = g_utf8_get_char(ptr_c);
-      if (!_owl_fmtext_is_format_char(c)) {
-	chwidth = wcwidth(c);
-      
-	if (col + chwidth > bcol)
-	  break;
-	if (col >= acol) {
-	  if (st == 0) {
-	    ptr_s = ptr_c;
-	    padding = col - acol;
-	    ++st;
-	  }
-	}
-	col += chwidth;
-	chwidth = 0;
-      }
-      ptr_c = g_utf8_next_char(ptr_c);
-    }
-    if (st) {
-      /* lead padding */
-      owl_fmtext_append_spaces(out, padding);
-      if (ptr_c[0] & 0x80) {
-	if (col + chwidth == bcol)
-	  ptr_c = g_utf8_next_char(ptr_c);
-	_owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - 1 - in->textbuff);	
-	owl_fmtext_append_normal(out, "\n");
-      }
-      else {
-	_owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
-      }
-    }
-    else {
+    /* we need to check that we won't run over here */
+    len=bcol-acol;
+    if (len > (ptr2-(ptr1+acol))) {
+      /* the whole line fits with room to spare, don't take a full 'len' */
+      len=ptr2-(ptr1+acol);
+    }
+    if (len>last-ptr1) {
+      /* the whole rest of the text fits with room to spare, adjust for it */
+      len-=(last-ptr1);
+    }
+    if (len<=0) {
+      /* saftey check */
       owl_fmtext_append_normal(out, "\n");
-    }
-    ptr_s = g_utf8_next_char(ptr_e);
+      ptr1=ptr2+1;
+      continue;
+    }
+
+    offset=ptr1-in->textbuff;
+    _owl_fmtext_append_fmtext(out, in, offset+acol, offset+acol+len);
+
+    ptr1=ptr2+1;
   }
 }
@@ -477,11 +381,8 @@
 
 /* set the charater at 'index' to be 'char'.  If index is out of
- * bounds don't do anything. If c or char at index is not ASCII, don't
- * do anything because it's not UTF-8 safe. */
-void owl_fmtext_set_char(owl_fmtext *f, int index, char ch)
+ * bounds don't do anything */
+void owl_fmtext_set_char(owl_fmtext *f, int index, int ch)
 {
   if ((index < 0) || (index > f->textlen-1)) return;
-  /* NOT ASCII*/
-  if (f->textbuff[index] & 0x80 || ch & 0x80) return; 
   f->textbuff[index]=ch;
 }
@@ -499,8 +400,37 @@
   dst->textlen=src->textlen;
   dst->textbuff=owl_malloc(mallocsize);
+  dst->fmbuff=owl_malloc(mallocsize);
+  dst->fgcolorbuff=owl_malloc(mallocsize * sizeof(short));
+  dst->bgcolorbuff=owl_malloc(mallocsize * sizeof(short));
   memcpy(dst->textbuff, src->textbuff, src->textlen+1);
-  dst->default_attrs = src->default_attrs;
-  dst->default_fgcolor = src->default_fgcolor;
-  dst->default_bgcolor = src->default_bgcolor;
+  memcpy(dst->fmbuff, src->fmbuff, src->textlen);
+  memcpy(dst->fgcolorbuff, src->fgcolorbuff, src->textlen * sizeof(short));
+  memcpy(dst->bgcolorbuff, src->bgcolorbuff, src->textlen * sizeof(short));
+}
+
+/* highlight all instances of "string".  Return the number of
+ * instances found.  This is a case insensitive search.
+ */
+int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string)
+{
+
+  int found, len;
+  char *ptr1, *ptr2;
+
+  len=strlen(string);
+  found=0;
+  ptr1=f->textbuff;
+  while (ptr1-f->textbuff <= f->textlen) {
+    ptr2=stristr(ptr1, string);
+    if (!ptr2) return(found);
+
+    found++;
+    _owl_fmtext_add_attr(f, OWL_FMTEXT_ATTR_REVERSE,
+                         ptr2 - f->textbuff,
+                         ptr2 - f->textbuff + len - 1);
+
+    ptr1=ptr2+len;
+  }
+  return(found);
 }
 
@@ -510,4 +440,5 @@
 int owl_fmtext_search(owl_fmtext *f, char *string)
 {
+
   if (stristr(f->textbuff, string)) return(1);
   return(0);
@@ -750,4 +681,7 @@
 {
   if (f->textbuff) owl_free(f->textbuff);
+  if (f->fmbuff) owl_free(f->fmbuff);
+  if (f->fgcolorbuff) owl_free(f->fgcolorbuff);
+  if (f->bgcolorbuff) owl_free(f->bgcolorbuff);
 }
 
Index: functions.c
===================================================================
--- functions.c	(revision 36172860060e404e761fc6fd5503c09ef88bd83d)
+++ functions.c	(revision 36172860060e404e761fc6fd5503c09ef88bd83d)
@@ -1606,5 +1606,5 @@
 	  sprintf(buff, "  Field %i   : ", i+1);
 	  
-	  ptr=owl_zephyr_get_field_as_utf8(n, i+1);
+	  ptr=owl_zephyr_get_field(n, i+1);
 	  len=strlen(ptr);
 	  if (len<30) {
@@ -2599,11 +2599,5 @@
   }
   /* downcase it */
-  {
-    char *temp = g_utf8_strdown(filtname, -1);
-    if (temp) {
-      owl_free(filtname);
-      filtname = temp;
-    }
-  }
+  downstr(filtname);
   /* turn spaces, single quotes, and double quotes into dots */
   owl_text_tr(filtname, ' ', '.');
@@ -3030,5 +3024,5 @@
   char *quoted;
 
-  buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
+  buff=malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
   strcpy(buff, "class");
   if (!strcmp(class, "*")) {
@@ -3334,5 +3328,5 @@
           if (ret==0) {
             for (x=0; x<numlocs; x++) {
-              line=owl_malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
+              line=malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
               tmp=short_zuser(user);
               sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
@@ -3440,5 +3434,5 @@
 	  _exit(127);
 	}
-	parsed=owl_realloc(parsed, sizeof(*parsed) * (myargc+1));
+	parsed=realloc(parsed, sizeof(*parsed) * (myargc+1));
 	parsed[myargc] = NULL;
 	
Index: global.c
===================================================================
--- global.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
+++ global.c	(revision ad15610ead2550219224b67ce4c2d7da2819e4df)
@@ -545,5 +545,5 @@
     len+=strlen(argv[i])+5;
   }
-  g->startupargs=owl_malloc(len+5);
+  g->startupargs=malloc(len+5);
 
   strcpy(g->startupargs, "");
Index: logging.c
===================================================================
--- logging.c	(revision 28ee32b3f0b785ed3f83357207feda49cfdb61b4)
+++ logging.c	(revision d0961fe0bc68cec33bc23afbae4928bbd861d718)
@@ -155,9 +155,7 @@
     to = owl_sprintf("jabber:%s", owl_message_get_recipient(m));
   } else if (owl_message_is_type_aim(m)) {
-    char *temp2;
     temp = owl_aim_normalize_screenname(owl_message_get_recipient(m));
-    temp2 = g_utf8_strdown(temp,-1);
-    to = owl_sprintf("aim:%s", temp2);
-    owl_free(temp2);
+    downstr(temp);
+    to = owl_sprintf("aim:%s", temp);
     owl_free(temp);
   } else {
@@ -269,10 +267,9 @@
   } else if (owl_message_is_type_aim(m)) {
     /* we do not yet handle chat rooms */
-    char *normalto, *temp;
-    temp = owl_aim_normalize_screenname(owl_message_get_sender(m));
-    normalto = g_utf8_strdown(temp, -1);
+    char *normalto;
+    normalto=owl_aim_normalize_screenname(owl_message_get_sender(m));
+    downstr(normalto);
     from=frombuff=owl_sprintf("aim:%s", normalto);
     owl_free(normalto);
-    owl_free(temp);
   } else if (owl_message_is_type_loopback(m)) {
     from=frombuff=owl_strdup("loopback");
@@ -293,5 +290,5 @@
 
   ch=frombuff[0];
-  if (!g_ascii_isalnum(ch)) from="weird";
+  if (!isalnum(ch)) from="weird";
 
   for (i=0; i<len; i++) {
@@ -302,11 +299,5 @@
 
   if (!personal) {
-    if (strcmp(from, "weird")) {
-      char* temp = g_utf8_strdown(frombuff, -1);
-      if (temp) {
-	owl_free(frombuff);
-	from = frombuff = temp;
-      }
-    }
+    if (strcmp(from, "weird")) downstr(from);
   }
 
Index: message.c
===================================================================
--- message.c	(revision 62016463b9add34672342c83beef28abe3f75476)
+++ message.c	(revision 671136196c3c4101fda5fa092486004af404dd21)
@@ -79,5 +79,5 @@
     owl_list_append_element(&(m->attributes), pair);
   }
-  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
+  owl_pair_set_value(pair, owl_strdup(attrvalue));
 }
 
@@ -493,5 +493,5 @@
 {
   if(m->zwriteline) owl_free(m->zwriteline);
-  m->zwriteline=owl_strdup(line);
+  m->zwriteline=strdup(line);
 }
 
@@ -537,8 +537,16 @@
   owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a);
   owl_fmtext_truncate_cols(&a, acol, bcol, &b);
-  owl_fmtext_colorize(&b, fgcolor);
-  owl_fmtext_colorizebg(&b, bgcolor);
-
-  owl_fmtext_curs_waddstr(&b, win, owl_global_is_search_active(&g));
+  if (fgcolor!=OWL_COLOR_DEFAULT) {
+    owl_fmtext_colorize(&b, fgcolor);
+  }
+  if (bgcolor!=OWL_COLOR_DEFAULT) {
+    owl_fmtext_colorizebg(&b, bgcolor);
+  }
+
+  if (owl_global_is_search_active(&g)) {
+    owl_fmtext_search_and_highlight(&b, owl_global_get_search_string(&g));
+  }
+      
+  owl_fmtext_curs_waddstr(&b, win);
 
   owl_fmtext_free(&a);
@@ -882,5 +890,5 @@
   }
 
-  m->zwriteline=owl_strdup("");
+  m->zwriteline=strdup("");
 
   /* save the hostname */
@@ -964,5 +972,5 @@
   }
 
-  m->zwriteline=owl_strdup("");
+  m->zwriteline=strdup("");
 
   owl_message_set_body(m, "<uninitialized>");
Index: owl.c
===================================================================
--- owl.c	(revision 89f5338caeb1828d0000cccaf478f1808203a6b1)
+++ owl.c	(revision 89f5338caeb1828d0000cccaf478f1808203a6b1)
@@ -48,5 +48,4 @@
 #include <termios.h>
 #include <sys/stat.h>
-#include <locale.h>
 #include "owl.h"
 
@@ -93,7 +92,4 @@
   debug=0;
   initialsubs=1;
-
-  setlocale(LC_ALL, "");
-  
   if (argc>0) {
     argv++;
Index: owl.h
===================================================================
--- owl.h	(revision 9866c3aac7b8bd2779303753d2e1352f405b2baf)
+++ owl.h	(revision 18e28a410181648e32a57fac7edf9942a364a49d)
@@ -52,7 +52,5 @@
 #include <termios.h>
 #include <libfaim/aim.h>
-#include <wchar.h>
 #include "config.h"
-#include "glib.h"
 #ifdef HAVE_LIBZEPHYR
 #include <zephyr/zephyr.h>
@@ -100,24 +98,4 @@
 #define OWL_FMTEXT_ATTR_REVERSE   2
 #define OWL_FMTEXT_ATTR_UNDERLINE 4
-
-#define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/
-#define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 )
-#define OWL_FMTEXT_UC_ATTR_MASK 0x7
-#define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 )
-#define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE
-#define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 )
-#define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100
-#define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR )
-#define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR )
-#define OWL_FMTEXT_UC_COLOR_MASK 0xFF
-#define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200)
-#define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4'
-
-#define OWL_FMTEXT_UTF8_ATTR_NONE "\xf4\x80\xa0\x80"
-#define OWL_FMTEXT_UTF8_FGDEFAULT "\xf4\x80\x94\x80"
-#define OWL_FMTEXT_UTF8_BGDEFAULT "\xf4\x80\x96\x80"
-
-
-
 
 #define OWL_COLOR_BLACK     0
@@ -276,7 +254,7 @@
   int bufflen;
   char *textbuff;
-  char default_attrs;
-  short default_fgcolor;
-  short default_bgcolor;
+  char *fmbuff;
+  short *fgcolorbuff;
+  short *bgcolorbuff;
 } owl_fmtext;
 
Index: perlconfig.c
===================================================================
--- perlconfig.c	(revision 5376a95c0ff753a89c734d966bf048447b90f3db)
+++ perlconfig.c	(revision ad15610ead2550219224b67ce4c2d7da2819e4df)
@@ -55,5 +55,5 @@
     j=owl_zephyr_get_num_fields(owl_message_get_notice(m));
     for (i=0; i<j; i++) {
-      ptr=owl_zephyr_get_field_as_utf8(owl_message_get_notice(m), i+1);
+      ptr=owl_zephyr_get_field(owl_message_get_notice(m), i+1);
       av_push(av_zfields, newSVpvn(ptr, strlen(ptr)));
       owl_free(ptr);
Index: text.c
===================================================================
--- text.c	(revision dd24b6a9702baf822973cf963adfd8b55978b775)
+++ text.c	(revision 72db971652f37640c13d75944eeb6eaf0fff645a)
@@ -50,66 +50,39 @@
 void owl_text_truncate_cols(char *out, char *in, int acol, int bcol)
 {
-  char *ptr_s, *ptr_e, *ptr_c, *tmpbuff, *last;
-  int col, cnt, padding;
-  
+  char *ptr1, *ptr2, *tmpbuff, *last;
+  int len;
+
   tmpbuff=owl_malloc(strlen(in)+20);
 
   strcpy(tmpbuff, "");
   last=in+strlen(in)-1;
-  ptr_s=in;
-  while (ptr_s<last) {
-    ptr_e=strchr(ptr_s, '\n');
-    if (!ptr_e) {
+  ptr1=in;
+  while (ptr1<last) {
+    ptr2=strchr(ptr1, '\n');
+    if (!ptr2) {
       /* but this shouldn't happen if we end in a \n */
       break;
     }
     
-    if (ptr_e==ptr_s) {
+    if (ptr2==ptr1) {
       strcat(tmpbuff, "\n");
-      ptr_s++;
-      continue;
-    }
-
-    col = 0;
-    cnt = 0;
-    padding = 0;
-    ptr_c = ptr_s;
-    while(col < bcol && ptr_c < ptr_e) {
-      gunichar c = g_utf8_get_char(ptr_c);
-      if (col + wcwidth(c) > bcol) break;
-      col += wcwidth(c);
-      ptr_c = g_utf8_next_char(ptr_c);
-      if (col >= acol) {
-	if (cnt == 0) {
-	  ptr_s = ptr_c;
-	  padding = col - acol;
-	}
-	++cnt;
-      }
-    }
-    if (cnt) {
-      while(padding-- > 0) {
-	strcat(tmpbuff, " ");
-      }
-      strncat(tmpbuff, ptr_s, ptr_c - ptr_s - 1);
-    }
-    strcat(tmpbuff, "\n");
-    ptr_s = ptr_e + 1;
-#if 0
+      ptr1++;
+      continue;
+    }
+
     /* we need to check that we won't run over here */
-    if ( (ptr_e-ptr_s) < (bcol-acol) ) {
-      len=ptr_e-(ptr_s+acol);
+    if ( (ptr2-ptr1) < (bcol-acol) ) {
+      len=ptr2-(ptr1+acol);
     } else {
       len=bcol-acol;
     }
-    if ((ptr_s+len)>=last) {
-      len-=last-(ptr_s+len);
-    }
-
-    strncat(tmpbuff, ptr_s+acol, len);
+    if ((ptr1+len)>=last) {
+      len-=last-(ptr1+len);
+    }
+
+    strncat(tmpbuff, ptr1+acol, len);
     strcat(tmpbuff, "\n");
 
-    ptr_s=ptr_e+1;
-#endif
+    ptr1=ptr2+1;
   }
   strcpy(out, tmpbuff);
@@ -302,16 +275,19 @@
 char *stristr(char *a, char *b)
 {
-  char *x, *y;
-  char *ret = NULL;
-  if ((x = g_utf8_casefold(a, -1)) != NULL) {
-    if ((y = g_utf8_casefold(b, -1)) != NULL) {
-      ret = strstr(x, y);
-      if (ret != NULL) {
-	ret = ret - x + a;
-      }
-      g_free(y);
-    }
-    g_free(x);
-  }
+  char *x, *y, *ret;
+
+  if ((x=owl_strdup(a))==NULL) return(NULL);
+  if ((y=owl_strdup(b))==NULL) return(NULL);
+  downstr(x);
+  downstr(y);
+  ret=strstr(x, y);
+  if (ret==NULL) {
+    owl_free(x);
+    owl_free(y);
+    return(NULL);
+  }
+  ret=ret-x+a;
+  owl_free(x);
+  owl_free(y);
   return(ret);
 }
@@ -320,15 +296,7 @@
 int only_whitespace(char *s)
 {
-  if (g_utf8_validate(s,-1,NULL)) {
-    char *p;
-    for(p = s; p[0]; p=g_utf8_next_char(p)) {
-      if (!g_unichar_isspace(g_utf8_get_char(p))) return 0;
-    }
-  }
-  else {
-    int i;
-    for (i=0; s[i]; i++) {
-      if (!isspace((int) s[i])) return(0);
-    }
+  int i;
+  for (i=0; s[i]; i++) {
+    if (!isspace((int) s[i])) return(0);
   }
   return(1);
@@ -359,5 +327,5 @@
   tolen  = strlen(to);
   fromlen  = strlen(from);
-  out = owl_malloc(outlen);
+  out = malloc(outlen);
 
   while (in[inpos]) {
Index: util.c
===================================================================
--- util.c	(revision 7b1d048f7f97c017e859a6805cd148da213a3bc3)
+++ util.c	(revision 89f5338caeb1828d0000cccaf478f1808203a6b1)
@@ -399,4 +399,13 @@
 }
 
+/* downcase the string 'foo' */
+void downstr(char *foo)
+{
+  int i;
+  for (i=0; foo[i]!='\0'; i++) {
+    foo[i]=tolower(foo[i]);
+  }
+}
+
 /* Caller must free response. 
  * Takes in strings which are space-separated lists of tokens
@@ -437,35 +446,49 @@
 void *owl_malloc(size_t size)
 {
-  return(g_malloc(size));
+  return(malloc(size));
 }
 
 void owl_free(void *ptr)
 {
-  g_free(ptr);
+  free(ptr);
 }
 
 char *owl_strdup(const char *s1)
 {
-  return(g_strdup(s1));
+  return(strdup(s1));
 }
 
 void *owl_realloc(void *ptr, size_t size)
 {
-  return(g_realloc(ptr, size));
+  return(realloc(ptr, size));
 }
 
 /* allocates memory and returns the string or null.
  * caller must free the string. 
+ * from Linux sprintf man page. 
  */
 char *owl_sprintf(const char *fmt, ...)
 {
+  int n, size = 100;
+  char *p;
   va_list ap;
-  char *ret = NULL;
-  va_start(ap, fmt);
-  ret = g_strdup_vprintf(fmt, ap);
-  va_end(ap);
-  return ret;
-}
-
+  if ((p = owl_malloc (size)) == NULL) return (NULL);
+  while (1) {
+    /* Try to print in the allocated space. */
+    va_start(ap, fmt);
+    n = vsnprintf (p, size, fmt, ap);
+    va_end(ap);
+    /* If that worked, return the string. */
+    if (n > -1 && n < size)
+      return p;
+    /* Else try again with more space. */
+    if (n > -1)    /* glibc 2.1 */
+      size = n+1; /* precisely what is needed */
+    else           /* glibc 2.0 */
+      size *= 2;  /* twice the old size */
+    if ((p = owl_realloc (p, size)) == NULL)
+      return NULL;
+  }
+}
 
 /* Return the owl color associated with the named color.  Return -1
@@ -753,81 +776,9 @@
 }
 
-char * owl_get_datadir()
-{
-  char * datadir = getenv("BARNOWL_DATA_DIR");
-  if(datadir != NULL)
-    return strchr(datadir, '=') + 1;
-  return DATADIR;
-}
-
-/* Strips format characters from a valid utf-8 string. Returns the
-   empty string if 'in' does not validate. */
-char * owl_strip_format_chars(char *in)
-{
-  char *r;
-  if (g_utf8_validate(in, -1, NULL)) {
-    char *s, *p;
-    r = owl_malloc(strlen(in)+1);
-    r[0] = '\0';
-    s = in;
-    p = strchr(s, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-    while(p) {
-      /* If it's a format character, copy up to it, and skip all
-	 immediately following format characters. */
-      if (_owl_fmtext_is_format_char(g_utf8_get_char(p))) {
-	strncat(r, s, p-s);
-	p = g_utf8_next_char(p);
-	while (p && _owl_fmtext_is_format_char(g_utf8_get_char(p))) {
-	  p = g_utf8_next_char(p);
-	}
-	s = p;
-	p = strchr(s, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-      }
-      else {
-	p = strchr(p+1, OWL_FMTEXT_UC_STARTBYTE_UTF8);
-      }
-    }
-    if (s) strcat(r,s);
-  }
-  else {
-    r = owl_strdup("");
-  }
-  return r;
-}
-
-/* If in is not UTF-8, convert from ISO-8859-1. We may want to allow
- * the caller to specify an alternative in the future. We also strip
- * out characters in Unicode Plane 16, as we use that plane internally
- * for formatting.
- */
-char * owl_validate_or_convert(char *in)
-{
-  if (g_utf8_validate(in, -1, NULL)) {
-    return owl_strip_format_chars(in);
-  }
-  else {
-    return g_convert(in, -1,
-		     "UTF-8", "ISO-8859-1",
-		     NULL, NULL, NULL);
-  }
-}
-/* Attempts to convert 'in' to ISO-8859-1. Returns that if possible,
-   else returns UTF-8.
- */
-char * owl_get_iso_8859_1_if_possible(char *in)
-{
-  char *out;
-  if (g_utf8_validate(in, -1, NULL)) {
-    out = g_convert(in, -1,
-		    "ISO-8859-1", "UTF-8",
-		    NULL, NULL, NULL);
-    if (!out) {
-      out = owl_strdup(in);
-    }
-  }
-  else {
-    out = owl_strdup("");
-  }
-  return out;
+char * owl_get_datadir() {
+    char * datadir = getenv("BARNOWL_DATA_DIR");
+    if(datadir != NULL)
+        return strchr(datadir, '=') + 1;
+    return DATADIR;
 }
 
Index: viewwin.c
===================================================================
--- viewwin.c	(revision 9866c3aac7b8bd2779303753d2e1352f405b2baf)
+++ viewwin.c	(revision 8721756cdb2a0ef8c380c35ec3bf73d2c0e1508a)
@@ -73,5 +73,5 @@
   owl_fmtext_truncate_cols(&fm1, v->rightshift, v->wincols-1+v->rightshift, &fm2);
 
-  owl_fmtext_curs_waddstr(&fm2, v->curswin, 0);
+  owl_fmtext_curs_waddstr(&fm2, v->curswin);
 
   /* print the message at the bottom */
Index: zcrypt.c
===================================================================
--- zcrypt.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
+++ zcrypt.c	(revision 9ceee9d93177e80e7794f45d5ba9e611169e4d55)
@@ -385,5 +385,5 @@
 
 /* Build a space-separated string from argv from elements between start  *
- * and end - 1.  owl_malloc()'s the returned string. */
+ * and end - 1.  malloc()'s the returned string. */
 char *BuildArgString(char **argv, int start, int end) {
   int len = 1;
@@ -397,5 +397,5 @@
 
   /* Allocate memory */
-  result = (char *)owl_malloc(len);
+  result = (char *)malloc(len);
   if (result) {
     /* Build the string */
@@ -482,5 +482,5 @@
       /* Prepare result to be returned */
       char *temp = keyfile;
-      keyfile = (char *)owl_malloc(strlen(temp) + 1);
+      keyfile = (char *)malloc(strlen(temp) + 1);
       if (keyfile) {
 	strcpy(keyfile, temp);
@@ -611,5 +611,5 @@
       }
       use_buffer = TRUE;
-      if ((inptr = inbuff = (char *)owl_malloc(MAX_RESULT)) == NULL) {
+      if ((inptr = inbuff = (char *)malloc(MAX_RESULT)) == NULL) {
 	printf("Memory allocation error\n");
 	return FALSE;
@@ -639,5 +639,5 @@
       printf("Could not run zwrite\n");
       if (freein && inbuff) {
-	owl_free(inbuff);
+	free(inbuff);
       }
       return(FALSE);
@@ -685,5 +685,5 @@
 
   /* Free the input buffer, if necessary */
-  if (freein && inbuff) owl_free(inbuff);
+  if (freein && inbuff) free(inbuff);
 
   return(!error);
Index: zephyr.c
===================================================================
--- zephyr.c	(revision 62016463b9add34672342c83beef28abe3f75476)
+++ zephyr.c	(revision 50e29e35c64d64e223d378d350a7bc4f038d78f5)
@@ -354,46 +354,8 @@
   return(owl_strdup(""));
 }
-
-char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
-{
-  int i, count, save;
-
-  /* If there's no message here, just run along now */
-  if (n->z_message_len == 0)
-    return(owl_strdup(""));
-
-  count=save=0;
-  for (i = 0; i < n->z_message_len; i++) {
-    if (n->z_message[i]=='\0') {
-      count++;
-      if (count == j) {
-	/* just found the end of the field we're looking for */
-	return(owl_validate_or_convert(n->z_message + save));
-      } else {
-	save = i + 1;
-      }
-    }
-  }
-  /* catch the last field, which might not be null terminated */
-  if (count == j - 1) {
-    char *tmp, *out;
-    tmp = owl_malloc(n->z_message_len-save+5);
-    memcpy(tmp, n->z_message+save, n->z_message_len-save);
-    tmp[n->z_message_len-save]='\0';
-    out = owl_validate_or_convert(tmp);
-    owl_free(tmp);
-    return out;
-  }
-
+#else
+char *owl_zephyr_get_field(void *n, int j)
+{
   return(owl_strdup(""));
-}
-#else
-char *owl_zephyr_get_field(void *n, int j)
-{
-  return(owl_strdup(""));
-}
-char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
-{
-  return owl_zephyr_get_field(n, j);
 }
 #endif
Index: zwrite.c
===================================================================
--- zwrite.c	(revision 7b1d048f7f97c017e859a6805cd148da213a3bc3)
+++ zwrite.c	(revision 1fe100c61c2374e461ad9d7c12938dbf52b015b6)
@@ -44,5 +44,5 @@
 	break;
       }
-      z->class=owl_get_iso_8859_1_if_possible(myargv[1]);
+      z->class=owl_strdup(myargv[1]);
       myargv+=2;
       myargc-=2;
@@ -52,5 +52,5 @@
 	break;
       }
-      z->inst=owl_get_iso_8859_1_if_possible(myargv[1]);
+      z->inst=owl_strdup(myargv[1]);
       myargv+=2;
       myargc-=2;
@@ -60,5 +60,5 @@
 	break;
       }
-      z->realm=owl_get_iso_8859_1_if_possible(myargv[1]);
+      z->realm=owl_strdup(myargv[1]);
       myargv+=2;
       myargc-=2;
@@ -68,5 +68,5 @@
 	break;
       }
-      z->zsig=owl_get_iso_8859_1_if_possible(myargv[1]);
+      z->zsig=owl_strdup(myargv[1]);
       myargv+=2;
       myargc-=2;
@@ -76,5 +76,5 @@
 	break;
       }
-      z->opcode=owl_get_iso_8859_1_if_possible(myargv[1]);
+      z->opcode=owl_strdup(myargv[1]);
       myargv+=2;
       myargc-=2;
@@ -93,7 +93,7 @@
       myargv++;
       myargc--;
-      z->message=owl_get_iso_8859_1_if_possible("");
+      z->message=owl_strdup("");
       while (myargc) {
-	z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
+	z->message=realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
 	strcat(z->message, myargv[0]);
 	strcat(z->message, " ");
@@ -113,5 +113,5 @@
     } else {
       /* anything unattached is a recipient */
-      owl_list_append_element(&(z->recips), owl_get_iso_8859_1_if_possible(myargv[0]));
+      owl_list_append_element(&(z->recips), strdup(myargv[0]));
       myargv++;
       myargc--;
@@ -146,5 +146,5 @@
 
     if (zsigowlvar && *zsigowlvar) {
-      z->zsig=owl_get_iso_8859_1_if_possible(zsigowlvar);
+      z->zsig=owl_strdup(zsigowlvar);
     } else if (zsigproc && *zsigproc) {
       FILE *file;
@@ -161,5 +161,5 @@
       if (!file) {
 	if (zsigzvar && *zsigzvar) {
-	  z->zsig=owl_get_iso_8859_1_if_possible(zsigzvar);
+	  z->zsig=owl_strdup(zsigzvar);
 	}
       } else {
@@ -175,7 +175,7 @@
       }
     } else if (zsigzvar) {
-      z->zsig=owl_get_iso_8859_1_if_possible(zsigzvar);
+      z->zsig=owl_strdup(zsigzvar);
     } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
-      z->zsig=owl_get_iso_8859_1_if_possible(pw->pw_gecos);
+      z->zsig=strdup(pw->pw_gecos);
       ptr=strchr(z->zsig, ',');
       if (ptr) {
@@ -218,5 +218,4 @@
   int i, j;
   char toline[LINE];
-  char *tmp = NULL;
 
   if (z->message) owl_free(z->message);
@@ -232,10 +231,8 @@
       }
     }
-    tmp = owl_get_iso_8859_1_if_possible(msg);
-    z->message=owl_sprintf("%s\n%s", toline, tmp);
+    z->message=owl_sprintf("%s\n%s", toline, msg);
   } else {
-    z->message=owl_get_iso_8859_1_if_possible(msg);
-  }
-  if (tmp) owl_free(tmp);
+    z->message=owl_strdup(msg);
+  }
 }
 
@@ -308,5 +305,5 @@
 {
   if (z->opcode) owl_free(z->opcode);
-  z->opcode=owl_get_iso_8859_1_if_possible(opcode);
+  z->opcode=owl_strdup(opcode);
 }
 
