diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./config/Makefile.config.in ./config/Makefile.config.in
--- ./config/Makefile.config.in	2005-03-02 20:28:12.000000000 +0100
+++ ./config/Makefile.config.in	2005-04-04 22:34:51.000000000 +0200
@@ -45,6 +45,7 @@
 REQUIRED_LABLGTK=@REQUIRED_LABLGTK@
 
 ICONV=@ICONV@
+LOCALECHARSET=@LOCALECHARSET@
 ZLIB=@ZLIB@
 COMPRESS=@COMPRESS@
 COMPRESS_EXT=@COMPRESS_EXT@
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./config/Makefile.in ./config/Makefile.in
--- ./config/Makefile.in	2005-04-04 21:36:42.000000000 +0200
+++ ./config/Makefile.in	2005-04-04 22:34:51.000000000 +0200
@@ -149,10 +149,7 @@
 
 endif
 
-ifeq ("$(ICONV)" , "yes")
-  LIBS_flags += -cclib -liconv
-#  LIBS_byte += -cclib -liconv
-endif
+LIBS_flags += -cclib "-liconv -lcharset"
 
 ifeq ("$(BROOSNET)", "yes")
   BROOSNET = \
@@ -213,7 +210,8 @@
   $(LIB)/md4_comp.c $(LIB)/md4_c.c \
   $(LIB)/gettext.ml4 $(LIB)/md5_c.c $(LIB)/$(SHA1_VERSION)_c.c \
   $(LIB)/tiger.c \
-  $(LIB)/stubs_c.c  $(LIB)/queues.ml
+  $(LIB)/stubs_c.c  $(LIB)/queues.ml \
+  $(LIB)/charsetstubs.c $(LIB)/charset.ml
 
 NET_SRCS = \
   $(NET)/basicSocket.ml \
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./config/configure.in ./config/configure.in
--- ./config/configure.in	2005-04-04 22:25:55.000000000 +0200
+++ ./config/configure.in	2005-04-04 22:34:51.000000000 +0200
@@ -1,6 +1,6 @@
 
 AC_REVISION(norev)
-AC_PREREQ(2.59)
+AC_PREREQ(2.56)
 AC_INIT(Makefile.config.in)
 AC_CONFIG_HEADER(config.h)
 
@@ -463,7 +463,29 @@
 fi
 
 ICONV=no
-AC_CHECK_LIB(iconv,iconv_open,[ICONV=yes])
+case $host in
+        *mingw*)
+           AC_CHECK_LIB(iconv,libiconv_open,[ICONV=yes])
+        ;;
+        *)
+           AC_CHECK_LIB(iconv,iconv_open,[ICONV=yes])
+        ;;
+esac
+if test "$ICONV" = "no"; then
+  echo "libiconv is missing, did you install the libraries and the developer packages?"
+  echo "Check libiconv is in your path."
+  exit 1
+fi
+
+LOCALECHARSET=no
+AC_CHECK_LIB(charset,locale_charset,[LOCALECHARSET=yes])
+if test "$LOCALECHARSET" = "no"; then
+  echo "libcharset is missing, it is part of the libiconv library."
+  echo "Did you install the libraries and the developer packages?"
+  echo "Check libiconv is in your path."
+  exit 1
+fi
+
 
 SHA1_VERSION=sha1new
 AC_CHECK_HEADERS(endian.h byteswap.h,,[
@@ -1041,6 +1063,7 @@
 AC_SUBST(MD4COMP)
 AC_SUBST(ZLIB)
 AC_SUBST(ICONV)
+AC_SUBST(LOCALECHARSET)
 
 AC_SUBST(AUDIO_GALAXY)
 AC_SUBST(OPEN_NAPSTER)
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/common/commonFile.ml ./src/daemon/common/commonFile.ml
--- ./src/daemon/common/commonFile.ml	2005-03-20 02:41:29.000000000 +0100
+++ ./src/daemon/common/commonFile.ml	2005-04-04 22:34:51.000000000 +0200
@@ -195,7 +195,7 @@
 
 let file_save_as (file : file) name =
   let file = as_file_impl file in
-  file.impl_file_ops.op_file_save_as file.impl_file_val name
+  file.impl_file_ops.op_file_save_as file.impl_file_val (Charset.to_locale name)
 
 let file_comment (file : file) =
   let file = as_file_impl file in
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/common/commonInteractive.ml ./src/daemon/common/commonInteractive.ml
--- ./src/daemon/common/commonInteractive.ml	2005-03-02 20:28:14.000000000 +0100
+++ ./src/daemon/common/commonInteractive.ml	2005-04-04 22:34:51.000000000 +0200
@@ -65,7 +65,7 @@
   
 let file_commited_name incoming_dir file =   
   let network = file_network file in
-  let best_name = file_best_name file in
+  let best_name = Charset.to_locale (file_best_name file) in
   (try Unix2.safe_mkdir incoming_dir with _ -> ());
   let new_name = 
     Filename.concat incoming_dir (canonize_basename  best_name)
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/common/guiDecoding.ml ./src/daemon/common/guiDecoding.ml
--- ./src/daemon/common/guiDecoding.ml	2005-04-04 21:36:46.000000000 +0200
+++ ./src/daemon/common/guiDecoding.ml	2005-04-04 22:34:51.000000000 +0200
@@ -68,16 +68,16 @@
   else
     Int64.of_int (get_int s pos), pos+4
       
-let get_string charset s pos = 
+let get_string s pos = 
   let len = get_int16 s pos in
   if len land 0xffff = 0xffff then
     let len = get_int s (pos+2) in
-    charset (String.sub s (pos+6) len), pos+6+len
+    (String.sub s (pos+6) len), pos+6+len
   else
-    charset (String.sub s (pos+2) len), pos+2+len
+    (String.sub s (pos+2) len), pos+2+len
 
 let get_string_bin s pos =
-  get_string ( fun s -> s ) s pos
+  get_string s pos
     
 let get_list f s pos =
   let len = get_int16 s pos in
@@ -95,67 +95,67 @@
 
 let get_bool s pos = (get_uint8 s pos) = 1
 
-let get_uid charset s pos =
-  let uid, pos = get_string charset s pos in
+let get_uid s pos =
+  let uid, pos = get_string s pos in
   Uid.of_string uid, pos
 
-let rec get_query charset s pos =
+let rec get_query s pos =
   let op = get_uint8 s pos in
   match op with
   | 0 ->
-      let list, pos = get_list (get_query charset) s (pos+1) in
+      let list, pos = get_list get_query s (pos+1) in
       Q_AND list, pos
   | 1 ->
-      let list, pos = get_list (get_query charset) s (pos+1) in
+      let list, pos = get_list get_query s (pos+1) in
       Q_OR list, pos
   | 2 ->
-      let q1, pos = get_query charset s (pos+1) in
-      let q2, pos = get_query charset s pos in
+      let q1, pos = get_query s (pos+1) in
+      let q2, pos = get_query  s pos in
       Q_ANDNOT (q1,q2), pos
   | 3 ->
-      let s1, pos = get_string charset s (pos+1) in
-      let q, pos = get_query charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let q, pos = get_query s pos in
       Q_MODULE (s1, q), pos
   
   | 4 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_KEYWORDS (s1,s2), pos
   
   | 5 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MINSIZE (s1,s2), pos
   | 6 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MAXSIZE (s1,s2), pos
   | 7 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_FORMAT (s1,s2), pos
   | 8 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MEDIA (s1,s2), pos
   | 9 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MP3_ARTIST (s1,s2), pos
   | 10 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MP3_TITLE (s1,s2), pos
   | 11 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MP3_ALBUM (s1,s2), pos
   | 12 -> 
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       Q_MP3_BITRATE (s1,s2), pos
   | 13 -> 
-      let list, pos = get_list (get_query charset) s (pos+1) in
+      let list, pos = get_list get_query s (pos+1) in
       Q_HIDDEN list, pos
   | _ -> assert false
 
@@ -166,9 +166,9 @@
   | 2 -> SubscribeSearch
   | _ -> assert false
 
-let get_search get_query charset proto s pos =
+let get_search get_query proto s pos =
   let num = get_int s pos in
-  let q, pos = get_query charset s (pos+4) in
+  let q, pos = get_query s (pos+4) in
   let max = get_int s pos in
   let stype, pos = 
     if proto >= 2 then
@@ -189,13 +189,13 @@
     search_network = net;
   }, pos
 
-let get_mp3 charset s pos =
+let get_mp3 s pos =
   let module M = Mp3tag.Id3v1 in
-  let title, pos = get_string charset s pos in
-  let artist, pos = get_string charset s pos in
-  let album, pos = get_string charset s pos in
-  let year, pos = get_string charset s pos in
-  let comment, pos = get_string charset s pos in
+  let title, pos = get_string s pos in
+  let artist, pos = get_string s pos in
+  let album, pos = get_string s pos in
+  let year, pos = get_string s pos in
+  let comment, pos = get_string s pos in
   let tracknum = get_int s pos in
   let genre = get_int s (pos+4) in
   {
@@ -219,15 +219,15 @@
     M.filesize = 0;
   }
   
-let get_format charset s pos =
+let get_format s pos =
   match get_uint8 s pos with
   | 0 -> FormatUnknown, pos+1
   | 1 ->
-      let s1, pos = get_string charset s (pos+1) in
-      let s2, pos = get_string charset s pos in
+      let s1, pos = get_string s (pos+1) in
+      let s2, pos = get_string s pos in
       FormatType (s1, s2), pos
   | 2 ->
-      let codec, pos = get_string charset s (pos+1) in
+      let codec, pos = get_string s (pos+1) in
       let width = get_int s pos in
       let height = get_int s (pos+4) in
       let fps = get_int s (pos+8) in
@@ -241,7 +241,7 @@
       }, pos+16
   
   | 3 ->
-      let t,pos = get_mp3 charset s (pos+1) in 
+      let t,pos = get_mp3 s (pos+1) in 
       MP3 (t, dummy_info), pos
   | _ -> assert false    
 
@@ -253,20 +253,20 @@
       get_uint64_32 s pos, pos + 4
   in i, pos
 
-let get_tag_name charset s pos =
-  let name, pos = get_string charset s pos in
+let get_tag_name s pos =
+  let name, pos = get_string s pos in
   let tag_name = field_of_string name in
   tag_name, pos
   
-let get_tag charset s pos =
-  let tag_name, pos = get_tag_name charset s pos in
+let get_tag s pos =
+  let tag_name, pos = get_tag_name s pos in
   let value, pos =
     match get_uint8 s pos with
       0 -> 
         Uint64 (get_uint64_32 s (pos+1)), pos+5
     | 1 -> 
         Fint64 (get_uint64_32 s (pos+1)), pos+5
-    | 2 -> let s, pos = get_string charset s (pos+1) in
+    | 2 -> let s, pos = get_string s (pos+1) in
         String s, pos
     | 3 -> Addr (get_ip s (pos+1)), pos+5
     | 4 -> Uint16 (get_int16 s (pos+1)), pos+3
@@ -276,21 +276,21 @@
   in
   { tag_name = tag_name; tag_value = value }, pos
 
-let get_result proto charset s pos =
+let get_result proto s pos =
   let num  = get_int s pos in
   let net = get_int s (pos+4) in
-  let names, pos = get_list (get_string charset) s (pos+8) in
+  let names, pos = get_list get_string s (pos+8) in
   let uids, pos = 
     if proto < 27 then
       [], pos+ 16
     else
-      get_list (get_uid charset) s pos
+      get_list get_uid s pos
   in
   let size, pos = get_uint64_2 proto s pos in
-  let format, pos = get_string charset s pos in
-  let t, pos = get_string charset s pos in
-  let tags, pos = get_list (get_tag charset) s pos in
-  let comment, pos = get_string charset s pos in
+  let format, pos = get_string s pos in
+  let t, pos = get_string s pos in
+  let tags, pos = get_list get_tag s pos in
+  let comment, pos = get_string s pos in
   let already_done = get_bool  s pos in
   let time, pos = 
     if proto < 27 then
@@ -313,22 +313,22 @@
     result_time = time;
   }, pos+1
 
-let get_message charset s pos =
+let get_message s pos =
   match get_uint8 s pos with
     0 ->
-      let s, pos = get_string charset s (pos+1) in
+      let s, pos = get_string s (pos+1) in
       ServerMessage s, pos
   | 1 ->
       let n = get_int s (pos+1) in
-      let s, pos = get_string charset s (pos+5) in
+      let s, pos = get_string s (pos+5) in
       PublicMessage (n, s), pos
   | 2 ->
       let n = get_int s (pos+1) in
-      let s, pos = get_string charset s (pos+5) in
+      let s, pos = get_string s (pos+5) in
       PrivateMessage (n,s), pos
   | _ -> assert false
 
-let get_file_state charset s pos =
+let get_file_state s pos =
   match get_uint8 s pos with
   | 0 -> FileDownloading, pos+1
   | 1 -> FilePaused, pos+1
@@ -336,21 +336,21 @@
   | 3 -> FileShared, pos+1
   | 4 -> FileCancelled, pos+1
   | 5 -> FileNew, pos+1
-  | 6 -> let s, pos = get_string charset s (pos+1) in FileAborted s, pos
+  | 6 -> let s, pos = get_string s (pos+1) in FileAborted s, pos
   | 7 -> FileQueued, pos+1
   | _ -> assert false
 
-let get_float charset s pos = 
-  let s, pos = get_string charset s pos in
+let get_float s pos = 
+  let s, pos = get_string s pos in
   float_of_string s, pos
 
-let get_float_date proto charset s pos = 
+let get_float_date proto s pos = 
   let date, pos =
     if proto > 23 then
       let date = get_int s pos in
       last_time () - date, pos + 4
     else
-    let s, pos = get_string charset s pos in
+    let s, pos = get_string s pos in
     BasicSocket.normalize_time (int_of_float (float_of_string s)), pos
   in
 (*  lprintf "get_float_date(%d): %d\n" proto date; *)
@@ -367,18 +367,18 @@
 let get_int_pos s pos =
   get_int s pos, pos + 4
   
-let get_file proto charset s pos = 
+let get_file proto s pos = 
   let num = get_int s pos in
   let net = get_int s (pos+4) in
   let names, pos = 
-    get_list (get_string charset) s (pos+8) in
+    get_list get_string s (pos+8) in
   let md4 = get_md4 s pos in
   let size,pos = get_uint64_2 proto s (pos+16) in
   let downloaded, pos = get_uint64_2 proto s pos in
   let file_all_sources = get_int s pos in
   let file_active_sources = get_int s (pos+4) in
-  let state, pos = get_file_state charset s (pos+8) in
-  let chunks, pos = get_string charset s pos in
+  let state, pos = get_file_state s (pos+8) in
+  let chunks, pos = get_string s pos in
   let availability, pos = 
     if proto > 17 then
       get_list (fun s pos ->
@@ -389,18 +389,18 @@
     else
     let avail, pos = get_string_bin s pos in
     [net, avail], pos in
-  let rate, pos = get_float charset s pos in
-  let chunks_age, pos = get_array (get_float_date proto charset) s pos in
-  let age, pos = get_float_date proto charset s pos in
-  let format, pos = get_format charset s pos in
+  let rate, pos = get_float s pos in
+  let chunks_age, pos = get_array (get_float_date proto) s pos in
+  let age, pos = get_float_date proto s pos in
+  let format, pos = get_format s pos in
   let name, pos = if proto >= 8 then
-      get_string charset s pos else List.hd names, pos in
+      get_string s pos else List.hd names, pos in
   let last_seen, pos = if proto >= 9 then 
       get_int s pos, pos+4 else BasicSocket.last_time (), pos in
   let priority, pos = if proto >= 12 then
       get_int s pos, pos+4 else 0, pos in
   let comment, pos = if proto > 21 then
-      get_string charset s pos
+      get_string s pos
     else "", pos in
   let names = List.map (fun name -> name, noips()) names in
   let last_seen = BasicSocket.last_time () - last_seen in
@@ -408,7 +408,7 @@
     if proto < 31 then
       [], pos
     else
-      get_list (get_uid charset) s pos
+      get_list get_uid s pos
   in
   (*
   assert (num = file_info_test.file_num);
@@ -491,32 +491,32 @@
   | _ -> assert false
 
 
-let get_addr charset s pos =
+let get_addr s pos =
   match get_uint8 s pos with
     0 ->
       let ip = get_ip s (pos+1) in
       Ip.addr_of_ip ip, pos+5
   | 1 ->
-      let name,pos = get_string charset s (pos+1) in
+      let name,pos = get_string s (pos+1) in
       Ip.addr_of_string name, pos
   | _ -> assert false
 
-let get_server proto charset s pos =
+let get_server proto s pos =
   let num = get_int s pos in
   let net = get_int s (pos+4) in
   let addr, pos = if proto < 2 then
       Ip.addr_of_ip (get_ip s (pos+8)), pos+12
     else 
-      get_addr charset s (pos+8)      
+      get_addr s (pos+8)      
   in
   let port = get_int16 s pos in
   let score = get_int s (pos+2) in
-  let tags, pos = get_list (get_tag charset) s (pos+6) in
+  let tags, pos = get_list get_tag s (pos+6) in
   let nusers, pos = get_int64_28 proto s pos in
   let nfiles, pos = get_int64_28 proto s pos in
   let state, pos = get_host_state proto s pos in
-  let name, pos = get_string charset s pos in
-  let description, pos = get_string charset s pos in
+  let name, pos = get_string s pos in
+  let description, pos = get_string s pos in
   let preferred = if proto > 28 then get_bool s pos else false in
   {
     server_num = num;
@@ -530,7 +530,7 @@
     server_state = state;
     server_name = name;
     server_description = description;
-  server_banner = "";
+    server_banner = "";
     server_users = None;
     server_preferred = preferred;
   }, pos
@@ -542,27 +542,27 @@
   | 2 -> client_contact_tag
   | _ -> assert false
 
-let get_kind charset s pos =
+let get_kind s pos =
   match get_uint8 s pos with
     0 ->
       let ip = get_ip s (pos+1) in
       let port = get_int16 s (pos+5) in
       Known_location (ip, port), pos+7
   | 1 ->
-      let name, pos = get_string charset s (pos+1) in
+      let name, pos = get_string s (pos+1) in
       let md4 = get_md4 s pos in
       Indirect_location (name, md4), pos+16
   | _ -> assert false
 
-let get_client proto charset s pos =
+let get_client proto s pos =
   if proto <= 18 then
     let num = get_int s pos in
     let net = get_int s (pos+4) in
-    let kind, pos = get_kind charset s (pos+8) in
+    let kind, pos = get_kind s (pos+8) in
     let state,pos = get_host_state proto s pos in
     let t = get_client_type s pos in
-    let tags, pos = get_list (get_tag charset) s (pos+1) in
-    let name, pos = get_string charset s pos in
+    let tags, pos = get_list get_tag s (pos+1) in
+    let name, pos = get_string s pos in
     let rating = get_int s pos in
     let chat_port = get_int s (pos+4) in
     {
@@ -587,18 +587,18 @@
   else
   let num = get_int s pos in
   let net = get_int s (pos+4) in
-  let kind, pos = get_kind charset s (pos+8) in
+  let kind, pos = get_kind s (pos+8) in
   let state,pos = get_host_state proto s pos in
   let t = get_client_type s pos in
-  let tags, pos = get_list (get_tag charset) s (pos+1) in
-  let name, pos = get_string charset s pos in
+  let tags, pos = get_list get_tag s (pos+1) in
+  let name, pos = get_string s pos in
   let rating = get_int s pos in
-  let software, pos = get_string charset s (pos+4) in
+  let software, pos = get_string s (pos+4) in
   let downloaded = get_int64 s pos in
   let uploaded = get_int64 s (pos+8) in
-(*  let sock_addr, pos = get_string charset s (pos+16) in *)
+(*  let sock_addr, pos = get_string s (pos+16) in *)
   let pos = pos + 16 in
-  let upload, pos = match get_string charset s pos with
+  let upload, pos = match get_string s pos with
       "", pos -> None, pos
     | s, pos -> Some s, pos
   in
@@ -609,7 +609,7 @@
   in
   let emulemod, pos =
     if proto >= 21 then
-      get_string charset s pos
+      get_string s pos
       else "", pos
   in 
   {
@@ -642,11 +642,11 @@
     NetworkHasUpload
   ]
   
-let get_network proto charset s pos =
+let get_network proto s pos =
   let num = get_int s pos in
-  let name, pos = get_string charset s (pos+4) in
+  let name, pos = get_string s (pos+4) in
   let enabled = get_bool s pos in
-  let config_file, pos = get_string charset s (pos+1) in
+  let config_file, pos = get_string s (pos+1) in
   let uploaded = get_int64 s pos in
   let downloaded = get_int64 s (pos+8) in
   let connected, flags, pos = 
@@ -680,13 +680,13 @@
   }, pos
 
 
-let get_user charset s pos = 
+let get_user s pos = 
   let num = get_int s pos in
   let md4 = get_md4 s (pos+4) in
-  let name, pos = get_string charset s (pos+20) in
+  let name, pos = get_string s (pos+20) in
   let ip = get_ip s pos in
   let port = get_int16 s (pos+4) in
-  let tags, pos = get_list (get_tag charset) s (pos+6) in
+  let tags, pos = get_list get_tag s (pos+6) in
   let server = get_int s pos in
   {
     user_num = num;
@@ -706,10 +706,10 @@
   | 2 -> RoomPaused
   | _ -> assert false
 
-let get_room proto charset s pos =
+let get_room proto s pos =
   let num = get_int s pos in
   let net = get_int s (pos+4) in
-  let name, pos = get_string charset s (pos+8) in
+  let name, pos = get_string s (pos+8) in
   let state = get_room_state s pos in
   let nusers,pos = if proto >= 3 then get_int s (pos+1), pos+5 else 0, pos+1 in
   {
@@ -722,10 +722,10 @@
     room_nusers = nusers;
   }, pos + 1 
 
-let get_shared_info proto charset s pos =
+let get_shared_info proto s pos =
   let num = get_int s pos in
   let network = get_int s (pos+4) in
-  let name, pos = get_string charset s (pos+8) in
+  let name, pos = get_string s (pos+8) in
   let size,pos = get_uint64_2 proto s pos in
   let uploaded = get_int64 s pos in
   let requests = get_int s (pos+8) in
@@ -739,10 +739,10 @@
     shared_uids = [];
   }
 
-let get_shared_info_version_10 proto charset s pos =
+let get_shared_info_version_10 proto s pos =
   let num = get_int s pos in
   let network = get_int s (pos+4) in
-  let name, pos = get_string charset s (pos+8) in
+  let name, pos = get_string s (pos+8) in
   let size,pos = get_uint64_2 proto s pos in
   let uploaded = get_int64 s pos in
   let requests = get_int s (pos+8) in
@@ -750,7 +750,7 @@
     if proto < 31 then
       [], pos+12
     else
-      get_list (get_uid charset) s (pos+12)
+      get_list get_uid s (pos+12)
   in
   {
     shared_num = num;
@@ -762,15 +762,15 @@
     shared_uids = uids;
   }
 
-  
-  
+
+
 (***************
 
      Decoding of messages from the GUI to the Core 
 
 ****************)
 
-let from_gui (proto : int array) charset opcode s =
+let from_gui (proto : int array) opcode s =
   try
 
     let proto = if opcode > from_gui_last_opcode then 0 else proto.(opcode) in    
@@ -786,29 +786,29 @@
     | 5
     | 52 -> 
         if proto < 14 then
-           let pass,_ = get_string charset s 2 in Password ("admin", pass)
+           let pass,_ = get_string s 2 in Password ("admin", pass)
         else
-        let pass,pos = get_string charset s 2 in
-        let login,pos = get_string charset s pos in
+        let pass,pos = get_string s 2 in
+        let login,pos = get_string s pos in
         Password (login, pass)
     | 6 -> 
         let local = get_bool s 2 in
-        let search, pos = get_search get_query charset proto s 3 in
+        let search, pos = get_search get_query  proto s 3 in
         search.search_type <- if local then LocalSearch else RemoteSearch;
         Search_query search
     | 7 -> 
-        let list, pos = get_list (get_string charset) s 2 in
+        let list, pos = get_list get_string s 2 in
         let result_num = get_int s pos in
         Download_query (list, result_num, false)
     
-    | 8 -> let string, pos = get_string charset s 2 in
+    | 8 -> let string, pos = get_string s 2 in
         lprintf "Received string: [%s]\n" (String.escaped string);
         Url string 
     | 9 -> let int = get_int s 2 in RemoveServer_query int
     | 10 ->
         let list, pos = get_list (fun s pos ->
-              let s1, pos = get_string charset s pos in
-              let s2, pos = get_string charset s pos in
+              let s1, pos = get_string s pos in
+              let s2, pos = get_string s pos in
               (s1,s2), pos) s 2 in
         SaveOptions_query list
     
@@ -822,7 +822,7 @@
     
     | 13 ->
         let int = get_int s 2 in 
-        let s, pos = get_string charset s 6 in
+        let s, pos = get_string s 6 in
         SaveFile (int, s)
     
     | 14 ->
@@ -840,7 +840,7 @@
     | 17 -> RemoveAllFriends
     
     | 18 -> 
-        let string, pos = get_string charset s 2 in
+        let string, pos = get_string s 2 in
         FindFriend string
     
     | 19 -> 
@@ -874,7 +874,7 @@
     
     | 26 ->
         let int = get_int s 2 in
-        let tag, pos = get_mp3 charset s 6 in
+        let tag, pos = get_mp3  s 6 in
         ModifyMp3Tags (int, tag)
     
     | 27 ->
@@ -882,12 +882,12 @@
         CloseSearch  (int, true)
     
     | 28 ->
-        let s1, pos = get_string charset s 2 in
-        let s2, pos = get_string charset s pos in
+        let s1, pos = get_string s 2 in
+        let s2, pos = get_string s pos in
         SetOption (s1, s2)
     
     | 29 ->
-        let s1, pos = get_string charset s 2 in
+        let s1, pos = get_string s 2 in
         Command s1
     
     | 30 ->
@@ -928,7 +928,7 @@
     
     | 39 ->
         let int = get_int s 2 in 
-        let room_message, pos = get_message charset s 6 in
+        let room_message, pos = get_message  s 6 in
         
         let msg = SendMessage (int, room_message) in
         
@@ -948,10 +948,10 @@
     | 41 ->
         let int = get_int s 2 in 
         BrowseUser  int
-    | 42 -> let s, pos = get_search get_query charset proto s 2 in Search_query s
+    | 42 -> let s, pos = get_search get_query  proto s 2 in Search_query s
     | 43 -> 
         let int = get_int s 2 in 
-        let message, pos = get_string charset s 6 in
+        let message, pos = get_string s 6 in
         MessageToClient (int, message)
     | 44 -> GetConnectedServers
     | 45 -> GetDownloadFiles
@@ -966,7 +966,7 @@
     | 49 -> RefreshUploadStats
     
     | 50 ->
-        let list, pos = get_list (get_string charset) s 2 in
+        let list, pos = get_list get_string s 2 in
         let result_num = get_int s pos in
         let force = get_bool s (pos+4) in
         Download_query (list, result_num, force)
@@ -997,7 +997,7 @@
 
     | 56 ->
         let num = get_int s 2 in
-        let new_name, pos = get_string charset s 6 in
+        let new_name, pos = get_string s 6 in
         RenameFile(num, new_name)
 
     | 57 ->
@@ -1020,7 +1020,7 @@
         
     | 63 ->
         let n = get_int s 2 in
-        let s, pos = get_string charset s 6 in
+        let s, pos = get_string s 6 in
         NetworkMessage (n, s)
         
     | 64 ->
@@ -1046,7 +1046,7 @@
      Decoding of messages from the Core to the GUI 
 
 ****************)
-      
+
 let dummy_option = 
   let module M = Options in
   {
@@ -1060,7 +1060,7 @@
     M.option_advanced = false;
   }
       
-let to_gui (proto : int array) charset opcode s =
+let to_gui (proto : int array)  opcode s =
   try
     let proto = if opcode > to_gui_last_opcode then 0 else proto.(opcode) in    
     
@@ -1080,8 +1080,8 @@
     | 1 ->
         let list, pos = get_list (fun s pos ->
               let module M = Options in
-              let name, pos = get_string charset s pos in
-              let value, pos = get_string charset s pos in
+              let name, pos = get_string s pos in
+              let value, pos = get_string s pos in
               { dummy_option with
                 M.option_name = name;
                 M.option_value = value;
@@ -1091,13 +1091,13 @@
     
     | 3 ->
         let list, pos = get_list (fun s pos ->
-              let name, pos = get_string charset s pos in
-              let q, pos = get_query charset s pos in
+              let name, pos = get_string s pos in
+              let q, pos = get_query  s pos in
               (name, q), pos) s 2 in
         DefineSearches list
     
     | 4 -> 
-        let r, pos = get_result proto charset s 2 in
+        let r, pos = get_result proto  s 2 in
         Result_info r
     
     | 5 ->
@@ -1111,13 +1111,13 @@
         Search_waiting (n1,n2)
     
     | 7 -> 
-        let file_info, pos = get_file proto charset s 2 in
+        let file_info, pos = get_file proto  s 2 in
         File_info file_info
     
     | 8 ->
         let n = get_int s 2 in
         let size,pos = get_uint64_2 proto s 6 in
-        let rate, pos = get_float charset s pos in
+        let rate, pos = get_float  s pos in
         File_downloaded (n, size, rate, BasicSocket.last_time ())
     
     | 9 ->
@@ -1148,11 +1148,11 @@
         Server_state (int,host_state)
     
     | 14 ->
-        let server_info, pos = get_server proto charset s 2 in
+        let server_info, pos = get_server proto  s 2 in
         Server_info server_info
     
     | 15 -> 
-        let client_info, pos = get_client proto charset s 2 in
+        let client_info, pos = get_client proto  s 2 in
         Client_info client_info
     
     | 16 -> 
@@ -1167,29 +1167,29 @@
     
     | 18 ->
         let n1 = get_int s 2 in
-        let s1, pos = get_string charset s 6 in
+        let s1, pos = get_string s 6 in
         let n2 = get_int s pos in          
         Client_file (n1, s1, n2)
     
     | 19 -> 
-        let string, pos = get_string charset s 2 in
+        let string, pos = get_string s 2 in
         Console string
     
     | 20 -> 
-        let network_info, pos = get_network proto charset s 2 in
+        let network_info, pos = get_network proto  s 2 in
         Network_info network_info
     
     | 21 ->
-        let user_info, pos = get_user charset s 2 in
+        let user_info, pos = get_user  s 2 in
         User_info user_info
     
     | 22 ->
-        let room_info, pos = get_room proto charset s 2 in
+        let room_info, pos = get_room proto  s 2 in
         Room_info room_info
     
     | 23 ->
         let int = get_int s 2 in
-        let room_message, pos = get_message charset s 6 in
+        let room_message, pos = get_message  s 6 in
         Room_message (int, room_message) 
     
     | 24 ->
@@ -1216,26 +1216,26 @@
           ndownloaded_files = 0;
         }
     
-    | 26 -> let s, pos = get_server proto charset s 2 in Server_info s
+    | 26 -> let s, pos = get_server proto  s 2 in Server_info s
     | 27 -> 
         let int = get_int s 2 in 
-        let message, pos = get_string charset s 6 in
+        let message, pos = get_string s 6 in
         MessageFromClient (int, message)
     
     | 28 -> 
-        let list, pos = get_list (get_server proto charset) s 2 in
+        let list, pos = get_list (get_server proto ) s 2 in
         ConnectedServers list
     
     | 29 ->
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadFiles list
     
     | 30 ->
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadedFiles list
     
     | 31 ->
-        let room_info, pos = get_room proto charset s 2 in
+        let room_info, pos = get_room proto  s 2 in
         Room_info room_info
     
     | 32 -> 
@@ -1243,7 +1243,7 @@
         let user = get_int s 6 in
         Room_remove_user (room, user)
     | 33 ->
-        let s = get_shared_info proto charset s 2 in
+        let s = get_shared_info proto  s 2 in
         Shared_file_info s
     
     | 34 ->
@@ -1257,15 +1257,15 @@
         Shared_file_unshared num
     
     | 36 -> 
-        let section, pos = get_string charset s 2 in
-        let message, pos = get_string charset s pos in 
-        let option, pos = get_string charset s pos in
+        let section, pos = get_string s 2 in
+        let message, pos = get_string s pos in 
+        let option, pos = get_string s pos in
         let module M = Options in
         let o = if proto > 16 then 
-            let optype, pos = get_string charset s pos in
-            let help, pos = get_string charset s pos in
-            let value, pos = get_string charset s pos in
-            let default, pos = get_string charset s pos in
+            let optype, pos = get_string s pos in
+            let help, pos = get_string s pos in
+            let value, pos = get_string s pos in
+            let default, pos = get_string s pos in
             let advanced = get_bool s pos in
             {
               M.option_desc = message;
@@ -1318,15 +1318,15 @@
         }
     
     | 38 -> 
-        let section, pos = get_string charset s 2 in
-        let message, pos = get_string charset s pos in 
-        let option, pos = get_string charset s pos in
+        let section, pos = get_string s 2 in
+        let message, pos = get_string s pos in 
+        let option, pos = get_string s pos in
         let module M = Options in
         let o = if proto > 16 then 
-            let optype, pos = get_string charset s pos in
-            let help, pos = get_string charset s pos in
-            let value, pos = get_string charset s pos in
-            let default, pos = get_string charset s pos in
+            let optype, pos = get_string s pos in
+            let help, pos = get_string s pos in
+            let value, pos = get_string s pos in
+            let default, pos = get_string s pos in
             let advanced = get_bool s pos in
             {
               M.option_desc = message;
@@ -1378,33 +1378,33 @@
         }
     
     |  40 ->
-        let file, pos = get_file proto charset s 2 in
+        let file, pos = get_file proto  s 2 in
         File_info file
     
     | 41 ->
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadFiles list
     
     | 42 ->
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadedFiles list
     
     | 43 ->
-        let file, pos = get_file proto charset s 2 in
+        let file, pos = get_file proto  s 2 in
         File_info file
     
     | 44 ->
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadFiles list
     
     | 45 ->
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadedFiles list
     
     | 46 ->
         let n = get_int s 2 in
         let size,pos = get_uint64_2 proto s 6 in
-        let rate, pos = get_float charset s pos in
+        let rate, pos = get_float  s pos in
         let last_seen = get_int s pos in
         File_downloaded (n, size, rate, 
           BasicSocket.last_time () - last_seen)
@@ -1412,7 +1412,7 @@
     | 47 -> BadPassword
     
     | 48 ->
-        let s = get_shared_info_version_10 proto charset s 2 in
+        let s = get_shared_info_version_10 proto  s 2 in
         Shared_file_info s      
     
     | 49 ->
@@ -1461,13 +1461,13 @@
         CleanTables (clients, servers)
 
     | 52 -> 
-        let file, pos = get_file proto charset s 2 in
+        let file, pos = get_file proto  s 2 in
         File_info file
     | 53 -> 
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadFiles list
     | 54 -> 
-        let list, pos = get_list (get_file proto charset) s 2 in
+        let list, pos = get_list (get_file proto ) s 2 in
         DownloadedFiles list
 
     | 55 ->
@@ -1478,11 +1478,11 @@
         Pending list
         
     | 57 ->
-        let s, pos = get_search get_string charset proto s 2 in
+        let s, pos = get_search get_string proto s 2 in
         Search s
         
     | 58 ->
-        let s, pos = get_string charset s 2 in 
+        let s, pos = get_string s 2 in 
         Version s
         
     | _ -> 
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/common/guiDecoding.mli ./src/daemon/common/guiDecoding.mli
--- ./src/daemon/common/guiDecoding.mli	2005-03-20 02:41:29.000000000 +0100
+++ ./src/daemon/common/guiDecoding.mli	2005-04-04 22:34:51.000000000 +0200
@@ -19,8 +19,8 @@
 
 exception FromGuiMessageNotImplemented
 
-val to_gui : int array -> (string -> string) -> int -> string -> GuiProto.to_gui
-val from_gui : int array -> (string -> string) -> int -> string -> GuiProto.from_gui
+val to_gui : int array -> int -> string -> GuiProto.to_gui
+val from_gui : int array -> int -> string -> GuiProto.from_gui
   
 val gui_cut_messages : (int -> string -> unit) -> TcpBufferedSocket.t -> 'a -> unit
   
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/common/guiEncoding.ml ./src/daemon/common/guiEncoding.ml
--- ./src/daemon/common/guiEncoding.ml	2005-04-04 21:36:46.000000000 +0200
+++ ./src/daemon/common/guiEncoding.ml	2005-04-04 22:34:51.000000000 +0200
@@ -71,9 +71,9 @@
 (* this else block already destroys backwards compatibility *)
 (* if len <= 0xfffff, how would the gui know what to do when len == 0xffff? *)
 
-let buf_string charset buf s =
+let buf_string buf s =
   (* charset conversion could generate longer strings *)
-  let s = charset s in
+  let s = Charset.to_utf8 s in
   let len = String.length s in
   if len < 0xffff then begin
       buf_int16 buf len;
@@ -85,21 +85,21 @@
     end 
 
 let buf_string_bin buf s =
-  buf_string ( fun s -> s ) buf s 
+  buf_string buf s 
     
-let buf_uid charset buf uid =
-  buf_string charset buf (Uid.to_string uid)
+let buf_uid buf uid =
+  buf_string buf (Uid.to_string uid)
 
-let buf_float charset buf f =
+let buf_float buf f =
   let i = int_of_float f in
-  buf_string charset buf (Printf.sprintf "%d.%d" i (int_of_float ((f -. float_of_int i) *. 100.)))
+  buf_string buf (Printf.sprintf "%d.%d" i (int_of_float ((f -. float_of_int i) *. 100.)))
 
-let buf_float_date proto charset buf date =
+let buf_float_date proto buf date =
 (*  lprintf "buf_float_date(%d): %d\n" proto date; *)
   if proto > 23 then
     buf_int buf (last_time () - date)
   else
-    buf_string charset buf (Printf.sprintf "%.0f" (BasicSocket.date_of_int date))
+    buf_string buf (Printf.sprintf "%.0f" (BasicSocket.date_of_int date))
 
 let buf_int_date proto buf date =
   if proto > 23 then
@@ -119,69 +119,69 @@
   else
     buf_int64_32 buf i
   
-let rec buf_query charset buf q =
+let rec buf_query buf q =
   match q with
     Q_AND list ->
       buf_int8 buf 0;
-      buf_list buf (buf_query charset) list
+      buf_list buf buf_query list
   | Q_OR list ->
       buf_int8 buf 1;
-      buf_list buf (buf_query charset) list
+      buf_list buf buf_query list
   | Q_ANDNOT (q1,q2) ->
       buf_int8 buf 2;
-      buf_query charset buf q1;
-      buf_query charset buf q2
+      buf_query buf q1;
+      buf_query buf q2
   | Q_MODULE (s, q) ->
       buf_int8 buf 3;
-      buf_string charset buf s;
-      buf_query charset buf q
+      buf_string buf s;
+      buf_query buf q
   | Q_KEYWORDS (s1,s2) ->
       buf_int8 buf 4;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MINSIZE (s1,s2) ->
       buf_int8 buf 5;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MAXSIZE (s1,s2) ->
       buf_int8 buf 6;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_FORMAT (s1,s2) ->
       buf_int8 buf 7;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MEDIA (s1,s2) ->
       buf_int8 buf 8;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MP3_ARTIST (s1,s2) ->
       buf_int8 buf 9;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MP3_TITLE (s1,s2) ->
       buf_int8 buf 10;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MP3_ALBUM (s1,s2) ->
       buf_int8 buf 11;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_MP3_BITRATE (s1,s2) ->
       buf_int8 buf 12;
-      buf_string charset buf s1;
-      buf_string charset buf s2
+      buf_string buf s1;
+      buf_string buf s2
   | Q_HIDDEN list ->
       buf_int8 buf 13;
-      buf_list buf (buf_query charset) list
+      buf_list buf buf_query list
   | Q_COMBO _ -> assert false
       
-let buf_tag charset buf t =
-  buf_string charset buf (string_of_field t.tag_name);
+let buf_tag buf t =
+  buf_string buf (string_of_field t.tag_name);
   match t.tag_value with
   | Uint64 s -> buf_int8 buf 0; buf_int64_32 buf s
   | Fint64 s -> buf_int8 buf 1; buf_int64_32 buf s
-  | String s -> buf_int8 buf 2; buf_string charset buf s
+  | String s -> buf_int8 buf 2; buf_string buf s
   | Addr ip -> buf_int8 buf 3; buf_ip buf ip
   | Uint16 n -> buf_int8 buf 4; buf_int16 buf n
   | Uint8 n -> buf_int8 buf 5; buf_int8 buf n
@@ -227,38 +227,38 @@
 let buf_bool buf b =
   buf_int8 buf (if b then 1 else 0)
       
-let buf_result proto charset buf r =
+let buf_result proto buf r =
   buf_int buf r.result_num;
   buf_int buf 0;
-  buf_list buf (buf_string charset) r.result_names;
+  buf_list buf buf_string r.result_names;
   if proto < 27 then
     buf_md4 buf Md4.null
   else
-    buf_list buf (buf_uid charset) r.result_uids;
+    buf_list buf buf_uid r.result_uids;
   buf_int64_2 proto buf r.result_size;
-  buf_string charset buf r.result_format;
-  buf_string charset buf r.result_type;
-  buf_list buf (buf_tag charset) r.result_tags;
-  buf_string charset buf r.result_comment;
+  buf_string buf r.result_format;
+  buf_string buf r.result_type;
+  buf_list buf buf_tag r.result_tags;
+  buf_string buf r.result_comment;
   buf_bool buf r.result_done;
   if proto > 26 then
     let date = r.result_time in
     buf_int buf (last_time () - date)
 
-let buf_user charset buf u =
+let buf_user buf u =
   buf_int buf u.user_num;
   buf_md4 buf u.user_md4;
-  buf_string charset buf u.user_name;
+  buf_string buf u.user_name;
   buf_ip buf u.user_ip;
   buf_int16 buf u.user_port;
-  buf_list buf (buf_tag charset) u.user_tags;
+  buf_list buf buf_tag u.user_tags;
   buf_int buf u.user_server
 
 let buf_room_state buf s =
   buf_int8 buf (match s with RoomOpened -> 0 | 
       RoomClosed -> 1 | RoomPaused -> 2 )
 
-let buf_file_state proto charset buf s =
+let buf_file_state proto buf s =
   match s with
   | FileDownloading ->   buf_int8 buf 0
   | FilePaused ->   buf_int8 buf 1
@@ -270,56 +270,56 @@
   | FileAborted s -> 
       if proto < 12 then buf_int8 buf 1 (* File Paused *)
       else
-        (buf_int8 buf 6; buf_string charset buf s)
+        (buf_int8 buf 6; buf_string buf s)
   | FileQueued -> buf_int8 buf (if proto < 14 then 0 else 7)
 
-let buf_room proto charset buf r =
+let buf_room proto buf r =
   buf_int buf r.room_num;
   buf_int buf r.room_network;
-  buf_string charset buf r.room_name;
+  buf_string buf r.room_name;
   buf_room_state buf r.room_state;
   if proto >= 3 then
     buf_int buf r.room_nusers
 
-let buf_message charset buf m =
+let buf_message buf m =
   match m with
-    ServerMessage s ->      buf_int8 buf 0; buf_string charset buf s 
-  | PublicMessage (n, s) -> buf_int8 buf 1; buf_int buf n; buf_string charset buf s
-  | PrivateMessage (n,s) -> buf_int8 buf 2; buf_int buf n; buf_string charset buf s
+    ServerMessage s ->      buf_int8 buf 0; buf_string buf s 
+  | PublicMessage (n, s) -> buf_int8 buf 1; buf_int buf n; buf_string buf s
+  | PrivateMessage (n,s) -> buf_int8 buf 2; buf_int buf n; buf_string buf s
 
-let buf_mp3 charset buf t =
+let buf_mp3 buf t =
   let module M = Mp3tag.Id3v1 in
-  buf_string charset buf t.M.title;
-  buf_string charset buf t.M.artist;
-  buf_string charset buf t.M.album;
-  buf_string charset buf t.M.year;
-  buf_string charset buf t.M.comment;
+  buf_string buf t.M.title;
+  buf_string buf t.M.artist;
+  buf_string buf t.M.album;
+  buf_string buf t.M.year;
+  buf_string buf t.M.comment;
   buf_int buf t.M.tracknum;
   buf_int buf t.M.genre
   
-let buf_format charset buf f =
+let buf_format buf f =
   match f with
   | FormatUnknown | FormatNotComputed _ -> buf_int8 buf 0
   | FormatType (s1, s2) -> buf_int8 buf 1; 
-      buf_string charset buf s1; buf_string charset buf s2
+      buf_string buf s1; buf_string buf s2
   | AVI avi -> buf_int8 buf 2;
-      buf_string charset buf avi.avi_codec;
+      buf_string buf avi.avi_codec;
       buf_int buf avi.avi_width;
       buf_int buf avi.avi_height;
       buf_int buf avi.avi_fps;
       buf_int buf avi.avi_rate;
   | MP3 (t, _) -> 
       buf_int8 buf 3;
-      buf_mp3 charset buf t
+      buf_mp3 buf t
       
-let buf_kind charset buf k =
+let buf_kind buf k =
   match k with
     Known_location (ip, port) -> 
       buf_int8 buf 0; buf_ip buf ip; buf_int16 buf port
   | Indirect_location (name, md4) ->
-      buf_int8 buf 1; buf_string charset buf name; buf_md4 buf md4
+      buf_int8 buf 1; buf_string buf name; buf_md4 buf md4
       
-let buf_partial_file proto charset buf f =
+let buf_partial_file proto buf f =
   buf_int buf f.file_num;
   if f.file_fields.Fields_file_info.file_network then begin
       buf_int8 buf 1;
@@ -327,7 +327,7 @@
     end;
   if f.file_fields.Fields_file_info.file_names then begin
       buf_int8 buf 2;
-      buf_list buf (buf_string charset) (List.map fst f.file_names);  
+      buf_list buf buf_string (List.map fst f.file_names);  
     end;      
   if f.file_fields.Fields_file_info.file_md4 then begin
       buf_int8 buf 3;
@@ -351,11 +351,11 @@
     end;
   if f.file_fields.Fields_file_info.file_state then begin
       buf_int8 buf 8;
-      buf_file_state proto charset buf f.file_state;  
+      buf_file_state proto buf f.file_state;  
     end;
   if f.file_fields.Fields_file_info.file_chunks then begin
       buf_int8 buf 9;
-      buf_string charset buf f.file_chunks;  
+      buf_string buf f.file_chunks;  
     end;
   if f.file_fields.Fields_file_info.file_availability then begin
       buf_int8 buf 10;
@@ -366,23 +366,23 @@
     end;
   if f.file_fields.Fields_file_info.file_download_rate then begin
       buf_int8 buf 11;
-      buf_float charset buf f.file_download_rate;  
+      buf_float buf f.file_download_rate;  
     end;
   if f.file_fields.Fields_file_info.file_chunks_age then begin
       buf_int8 buf 12;
-      buf_array buf (buf_float_date proto charset) f.file_chunks_age;  
+      buf_array buf (buf_float_date proto) f.file_chunks_age;  
     end;
   if f.file_fields.Fields_file_info.file_age then begin
       buf_int8 buf 13;
-      buf_float_date proto charset buf f.file_age;
+      buf_float_date proto buf f.file_age;
     end;
   if f.file_fields.Fields_file_info.file_format then begin
       buf_int8 buf 14;
-      buf_format charset buf f.file_format;
+      buf_format buf f.file_format;
     end;
   if f.file_fields.Fields_file_info.file_name then begin
       buf_int8 buf 15;
-      buf_string charset buf f.file_name;
+      buf_string buf f.file_name;
     end;
   if f.file_fields.Fields_file_info.file_last_seen then begin
       buf_int8 buf 16;
@@ -394,17 +394,17 @@
     end;
   if f.file_fields.Fields_file_info.file_comment then begin
       buf_int8 buf 18;
-      buf_string charset buf f.file_comment
+      buf_string buf f.file_comment
     end          
       
-let buf_file_field proto charset buf field =
+let buf_file_field proto buf field =
   match field with
   | Fields_file_info.File_network x ->
       buf_int8 buf 1;
       buf_int buf x
   | Fields_file_info.File_names x ->
       buf_int8 buf 2;
-      buf_list buf (buf_string charset) (List.map fst x);  
+      buf_list buf buf_string (List.map fst x);  
   | Fields_file_info.File_md4 x ->
       buf_int8 buf 3;
       buf_md4 buf x
@@ -422,10 +422,10 @@
       buf_int buf x
   | Fields_file_info.File_state x ->
       buf_int8 buf 8;
-      buf_file_state proto charset buf x
+      buf_file_state proto buf x
   | Fields_file_info.File_chunks x ->
       buf_int8 buf 9;
-      buf_string charset buf x
+      buf_string buf x
   | Fields_file_info.File_availability x ->
       buf_int8 buf 10;
       buf_list buf (fun buf (network, avail) ->
@@ -434,19 +434,19 @@
       ) x
   | Fields_file_info.File_download_rate x ->
       buf_int8 buf 11;
-      buf_float charset buf x
+      buf_float buf x
   | Fields_file_info.File_chunks_age x ->
       buf_int8 buf 12;
-      buf_array buf (buf_float_date proto charset) x
+      buf_array buf (buf_float_date proto) x
   | Fields_file_info.File_age x ->
       buf_int8 buf 13;
-      buf_float_date proto charset buf x
+      buf_float_date proto buf x
   | Fields_file_info.File_format x ->
       buf_int8 buf 14;
-      buf_format charset buf x
+      buf_format buf x
   | Fields_file_info.File_name x ->
       buf_int8 buf 15;
-      buf_string charset buf x
+      buf_string buf x
   | Fields_file_info.File_last_seen x ->
       buf_int8 buf 16;
       buf_int buf (compute_last_seen x);
@@ -455,19 +455,19 @@
       buf_int buf x
   | Fields_file_info.File_comment x ->
       buf_int8 buf 18;
-      buf_string charset buf x
+      buf_string buf x
     
-let buf_file proto charset buf f =
+let buf_file proto buf f =
   buf_int buf f.file_num;
   buf_int buf f.file_network;  
-  buf_list buf (buf_string charset) (List.map fst f.file_names);  
+  buf_list buf buf_string (List.map fst f.file_names);  
   buf_md4 buf f.file_md4;  
   buf_int64_2 proto buf f.file_size;  
   buf_int64_2 proto buf f.file_downloaded;  
   buf_int buf f.file_all_sources;  
   buf_int buf f.file_active_sources;  
-  buf_file_state proto charset buf f.file_state;  
-  buf_string charset buf f.file_chunks;  
+  buf_file_state proto buf f.file_state;  
+  buf_string buf f.file_chunks;  
   if proto > 17 then
     buf_list buf (fun buf (network, avail) ->
         buf_int buf network;
@@ -477,81 +477,81 @@
     buf_string_bin buf (match f.file_availability with
         [] -> ""
       | (_, av) :: _ -> av);
-  buf_float charset buf f.file_download_rate;  
-  buf_array buf (buf_float_date proto charset) f.file_chunks_age;  
-  buf_float_date proto charset buf f.file_age;
+  buf_float buf f.file_download_rate;  
+  buf_array buf (buf_float_date proto) f.file_chunks_age;  
+  buf_float_date proto buf f.file_age;
 (* last, so that it can be safely discarded in partial implementations: *)
-  buf_format charset buf f.file_format;
+  buf_format buf f.file_format;
   if proto >= 8 then 
-    buf_string charset buf f.file_name;
+    buf_string buf f.file_name;
   if proto >= 9 then 
     let ls = compute_last_seen f.file_last_seen in
     buf_int buf ls;
     if proto >= 12 then
       buf_int buf f.file_priority;
     if proto > 21 then
-      buf_string charset buf f.file_comment;
+      buf_string buf f.file_comment;
     if proto > 30 then
-      buf_list buf (buf_uid charset) f.file_uids
+      buf_list buf buf_uid f.file_uids
       
-let buf_addr charset buf addr =
+let buf_addr buf addr =
   match addr with
     Ip.AddrIp ip ->
       buf_int8 buf 0;
       buf_ip buf ip
   | Ip.AddrName s ->
       buf_int8 buf 1;
-      buf_string charset buf s
+      buf_string buf s
   
-let buf_server proto charset buf s =
+let buf_server proto buf s =
   buf_int buf s.server_num;
   buf_int buf s.server_network;
   if proto < 2 then 
     buf_ip buf (Ip.ip_of_addr s.server_addr)
   else
-    buf_addr charset buf s.server_addr;    
+    buf_addr buf s.server_addr;    
   buf_int16 buf s.server_port;
   buf_int buf s.server_score;
-  buf_list buf (buf_tag charset) s.server_tags;
+  buf_list buf buf_tag s.server_tags;
   buf_int64_28 proto buf s.server_nusers;
   buf_int64_28 proto buf s.server_nfiles;
   buf_host_state proto buf s.server_state;
-  buf_string charset buf s.server_name;
-  buf_string charset buf s.server_description;
+  buf_string buf s.server_name;
+  buf_string buf s.server_description;
   if proto > 28 then 
     buf_bool buf s.server_preferred
-  
-let buf_client proto charset buf c =
+
+let buf_client proto buf c =
   buf_int buf c.client_num;
   buf_int buf c.client_network;
-  buf_kind charset buf c.client_kind;
+  buf_kind buf c.client_kind;
   buf_host_state proto buf c.client_state;
   buf_client_type buf c.client_type;
-  buf_list buf (buf_tag charset) c.client_tags;
-  buf_string charset buf c.client_name;
+  buf_list buf buf_tag c.client_tags;
+  buf_string buf c.client_name;
   buf_int buf c.client_rating;
   if proto <= 18 then begin
       buf_int buf c.client_chat_port
     end else 
     begin
-      buf_string charset buf c.client_software;
+      buf_string buf c.client_software;
       buf_int64 buf c.client_downloaded;
       buf_int64 buf c.client_uploaded;
       (match c.client_upload with
-          Some s -> buf_string charset buf s
-        | None -> buf_string charset buf "");
+          Some s -> buf_string buf s
+        | None -> buf_string buf "");
       if proto >= 20 then begin
           buf_int_date proto buf c.client_connect_time
       end;
       if proto >= 21 then
-        buf_string charset buf c.client_emulemod;
+        buf_string buf c.client_emulemod;
     end
     
-let buf_network proto charset buf n =
+let buf_network proto buf n =
   buf_int buf n.network_netnum;
-  buf_string charset buf n.network_netname;
+  buf_string buf n.network_netname;
   buf_bool buf n.network_enabled;
-  buf_string charset buf n.network_config_filename;
+  buf_string buf n.network_config_filename;
   buf_int64 buf n.network_uploaded;
   buf_int64 buf n.network_downloaded;
   if proto > 17 then begin
@@ -579,19 +579,19 @@
     | RemoteSearch -> 1
     | SubscribeSearch -> 2)
     
-let buf_search buf_query proto charset buf s = 
+let buf_search buf_query proto buf s = 
   buf_int buf s.search_num;
-  buf_query charset buf s.search_query;
+  buf_query buf s.search_query;
   buf_int buf s.search_max_hits;
   if proto >= 2 then
     buf_search_type buf s.search_type;
   if proto >= 16 then
     buf_int buf s.search_network
 
-let buf_shared_info proto charset buf s =
+let buf_shared_info proto buf s =
   buf_int buf s.shared_num;
   buf_int buf s.shared_network;
-  buf_string charset buf s.shared_filename;
+  buf_string buf s.shared_filename;
   buf_int64_2 proto buf s.shared_size;
   buf_int64 buf s.shared_uploaded;
   buf_int buf s.shared_requests;
@@ -599,7 +599,7 @@
     if proto < 31 then
       buf_md4 buf Md4.null
     else
-      buf_list buf (buf_uid charset) s.shared_uids
+      buf_list buf buf_uid s.shared_uids
 
 (***************
 
@@ -607,7 +607,7 @@
 
 ****************)
   
-let rec to_gui (proto : int array) charset buf t =
+let rec to_gui (proto : int array) buf t =
   try
     let buf_opcode buf opcode =
        if !verbose_gui_decoding then
@@ -627,17 +627,17 @@
         buf_opcode buf 1; 
         buf_list buf (fun buf o ->
             let module M = Options in
-            buf_string charset buf o.M.option_name; buf_string charset buf o.M.option_value
+            buf_string buf o.M.option_name; buf_string buf o.M.option_value
         ) list
     
     | DefineSearches list -> 
         buf_opcode buf 3;
         buf_list buf (fun buf (s, query) ->
-            buf_string charset buf s; buf_query charset buf query) list
+            buf_string buf s; buf_query buf query) list
     
     | Result_info r -> buf_opcode buf 4;
         let proto = proto.(4) in
-        buf_result proto charset buf r
+        buf_result proto buf r
     
     | Search_result (n1,n2, _) -> buf_opcode buf 5;
         buf_int buf n1; buf_int buf n2
@@ -650,14 +650,14 @@
         buf_opcode buf (if proto < 8 then 7 else 
           if proto < 9 then 40 else 
           if proto < 14 then 43 else 52);
-        buf_file proto charset buf file_info
+        buf_file proto buf file_info
     
     | File_downloaded (n, size, rate, last_seen) -> 
         let proto = proto.(46) in
         buf_opcode buf (if proto < 9 then 8 else 46);
         buf_int buf n; 
         buf_int64_2 proto buf size; 
-        buf_float charset buf rate; 
+        buf_float buf rate; 
         if proto > 8 then
           buf_int buf (compute_last_seen last_seen)
     
@@ -679,11 +679,11 @@
     | Server_info s -> 
         let proto = proto.(26) in
         buf_opcode buf (if proto < 2 then 14 else 26);
-        buf_server proto charset buf s
+        buf_server proto buf s
     
     | Client_info client_info -> buf_opcode buf 15;
         let proto = proto.(15) in
-        buf_client proto charset buf client_info
+        buf_client proto buf client_info
     
     | Client_state (int, host_state) -> buf_opcode buf 16;
         let proto = proto.(16) in
@@ -693,26 +693,26 @@
         buf_int buf int; buf_client_type buf client_type
     
     | Client_file (n1, s, n2) -> buf_opcode buf 18;
-        buf_int buf n1; buf_string charset buf s; buf_int buf n2
+        buf_int buf n1; buf_string buf s; buf_int buf n2
     
     | Console string -> buf_opcode buf 19;
-        buf_string charset buf string
+        buf_string buf string
     
     | Network_info network_info -> buf_opcode buf 20;
         let proto = proto.(20) in
-        buf_network proto charset buf network_info
+        buf_network proto buf network_info
     
     | User_info user_info -> buf_opcode buf 21;
-        buf_user charset buf user_info
+        buf_user buf user_info
     
     | Room_info room_info -> 
         let proto = proto.(31) in
         
         buf_opcode buf (if proto < 3 then 22 else 31);
-        buf_room proto charset buf room_info
+        buf_room proto buf room_info
     
     | Room_message (int, room_message) -> buf_opcode buf 23;
-        buf_int buf int; buf_message charset buf room_message
+        buf_int buf int; buf_message buf room_message
     
     | Room_add_user (n1,n2) -> buf_opcode buf 24;
         buf_int buf n1; buf_int buf n2
@@ -722,11 +722,11 @@
         if protocol < 3 then
 (* This message was previously send like that ... *)
           
-          to_gui proto charset buf (Room_message (0, PrivateMessage(num, msg)))
+          to_gui proto buf (Room_message (0, PrivateMessage(num, msg)))
         else begin
             buf_opcode buf 27;
             buf_int buf num;
-            buf_string charset buf msg
+            buf_string buf msg
           end
     
     | BadPassword -> buf_opcode buf 47
@@ -736,18 +736,19 @@
         buf_opcode buf (if proto < 8 then 29 else 
           if proto < 9 then 41 else
           if proto < 14 then  44 else 53);
-        buf_list buf (buf_file proto charset) list
+        buf_list buf (buf_file proto) list
     
     | DownloadedFiles list ->      
         let proto = proto.(54) in
         buf_opcode buf (if proto < 8 then 30 else 
           if proto < 9 then 42 else 
           if proto < 14 then  45 else 54);
-        buf_list buf (buf_file proto charset) list
+        buf_list buf (buf_file proto) list
     
-    | ConnectedServers list ->      buf_opcode buf 28;
+    | ConnectedServers list ->
         let proto = proto.(28) in
-        buf_list buf (buf_server proto charset) list
+        buf_opcode buf 28;
+        buf_list buf (buf_server proto) list
     
     | Client_stats s -> 
         let proto = proto.(49) in
@@ -780,16 +781,18 @@
                 end
             end                
     
-    | Room_remove_user (room, user) ->       buf_opcode buf 32;
+    | Room_remove_user (room, user) ->
+        buf_opcode buf 32;
         buf_int buf room;
         buf_int buf user
     
     | Shared_file_info  shared_info ->       
         let proto = proto.(48) in
         buf_opcode buf (if proto < 10 then 33 else 48);
-        buf_shared_info proto charset buf shared_info
+        buf_shared_info proto buf shared_info
     
-    | Shared_file_upload (num, upload,requests) ->    buf_opcode buf 34;
+    | Shared_file_upload (num, upload,requests) ->
+        buf_opcode buf 34;
         buf_int buf num;
         buf_int64 buf upload;
         buf_int buf requests
@@ -796,19 +800,20 @@
     | Shared_file_unshared num -> buf_opcode buf 35;
         buf_int buf num
     
-    | Add_section_option (section, o) -> buf_opcode buf 36;
+    | Add_section_option (section, o) ->
         let proto = proto.(36) in
         let module M = Options in
-        buf_string charset buf section;
+        buf_opcode buf 36;
+        buf_string buf section;
         let desc = if o.M.option_desc = "" 
           then o.M.option_name else o.M.option_desc in
-        buf_string charset buf desc;
-        buf_string charset buf o.M.option_name;
+        buf_string buf desc;
+        buf_string buf o.M.option_name;
         if proto > 16 then begin
-            buf_string charset buf o.M.option_type;
-            buf_string charset buf o.M.option_help;
-            buf_string charset buf o.M.option_value;
-            buf_string charset buf o.M.option_default;
+            buf_string buf o.M.option_type;
+            buf_string buf o.M.option_help;
+            buf_string buf o.M.option_value;
+            buf_string buf o.M.option_default;
             buf_bool buf o.M.option_advanced;
           end
         else
@@ -817,19 +822,20 @@
             | "Filename" -> 2
             | _ -> 0);
     
-    | Add_plugin_option (section, o) -> buf_opcode buf 38;
+    | Add_plugin_option (section, o) ->
         let proto = proto.(38) in
         let module M = Options in
-        buf_string charset buf section;
+        buf_opcode buf 38;
+        buf_string buf section;
         let desc = if o.M.option_desc = "" 
           then o.M.option_name else o.M.option_desc in
-        buf_string charset buf desc;
-        buf_string charset buf o.M.option_name;
+        buf_string buf desc;
+        buf_string buf o.M.option_name;
         if proto > 16 then begin
-            buf_string charset buf o.M.option_type;
-            buf_string charset buf o.M.option_help;
-            buf_string charset buf o.M.option_value;
-            buf_string charset buf o.M.option_default;
+            buf_string buf o.M.option_type;
+            buf_string buf o.M.option_help;
+            buf_string buf o.M.option_value;
+            buf_string buf o.M.option_default;
             buf_bool buf o.M.option_advanced;
           end        
         else
@@ -838,7 +844,8 @@
             | "Filename" -> 2
             | _ -> 0);
     
-    | File_remove_source (n1,n2) -> buf_opcode buf 50;
+    | File_remove_source (n1,n2) ->
+        buf_opcode buf 50;
         buf_int buf n1; buf_int buf n2
     
     | File_update_availability (file_num, client_num, avail) -> 
@@ -860,11 +867,11 @@
     
     | Search s ->
         let proto = proto.(57) in
-        buf_opcode buf 57; buf_search buf_string proto charset buf s
+        buf_opcode buf 57; buf_search buf_string proto buf s
     
     | Version s ->
         let proto = proto.(58) in
-        buf_opcode buf 58; buf_string charset buf s
+        buf_opcode buf 58; buf_string buf s
     
     | GiftServerAttach _ -> assert false
     | GiftServerStats _ -> assert false
@@ -878,7 +885,7 @@
 
 ****************)
 
-let rec from_gui (proto : int array) charset buf t =
+let rec from_gui (proto : int array) buf t =
   try
     let buf_opcode buf opcode =
        if !verbose_gui_decoding then
@@ -896,9 +903,9 @@
     | Password (login, pass) ->
         let proto = proto.(52) in
         buf_opcode buf (if proto < 14 then 5 else 52);
-        buf_string charset buf pass;
+        buf_string buf pass;
         if proto > 13 then 
-          buf_string charset buf login
+          buf_string buf login
     
     | Search_query search -> 
         let proto = proto.(42) in
@@ -908,22 +915,23 @@
           end else begin
             buf_opcode buf 42;          
           end;
-        buf_search buf_query proto charset buf search
+        buf_search buf_query proto buf search
+
     | Download_query (list, int, force) -> 
         let proto = proto.(50) in
         buf_opcode buf (if proto < 14 then 7 else 50);
-        buf_list buf (buf_string charset) list; 
+        buf_list buf buf_string list; 
         buf_int buf int;
         if proto > 13 then
           buf_bool buf force
     
     | Url string -> buf_opcode buf 8;
-        buf_string charset buf string
+        buf_string buf string
     | RemoveServer_query int -> buf_opcode buf 9;
         buf_int buf int
     | SaveOptions_query list -> buf_opcode buf 10;
         buf_list buf (fun buf (s1,s2) ->
-            buf_string charset buf s1; buf_string charset buf s2) list
+            buf_string buf s1; buf_string buf s2) list
     
     | RemoveDownload_query  int -> buf_opcode buf 11;
         buf_int buf int
@@ -932,7 +940,7 @@
     | ServerUsers_query  int -> buf_opcode buf 12;
         buf_int buf int
     | SaveFile (int, string) -> buf_opcode buf 13;
-        buf_int buf int; buf_string charset buf string
+        buf_int buf int; buf_string buf string
     | AddClientFriend  int -> buf_opcode buf 14;
         buf_int buf int
     | AddUserFriend  int -> buf_opcode buf 15;
@@ -941,7 +949,7 @@
         buf_int buf int
     | RemoveAllFriends -> buf_opcode buf 17;
     | FindFriend string -> buf_opcode buf 18;
-        buf_string charset buf string
+        buf_string buf string
     | ViewUsers  int -> buf_opcode buf 19;
         buf_int buf int
     | ConnectAll  int -> buf_opcode buf 20;
@@ -957,7 +965,7 @@
     | QueryFormat  int -> buf_opcode buf 25;
         buf_int buf int
     | ModifyMp3Tags (int, tag) -> buf_opcode buf 26;
-        buf_int buf int; buf_mp3 charset buf tag
+        buf_int buf int; buf_mp3 buf tag
     | CloseSearch  (int,bool) -> 
         let proto = proto.(53) in
         if proto < 15 then begin
@@ -969,9 +977,9 @@
             buf_bool buf bool;         
           end
     | SetOption (s1, s2) -> buf_opcode buf 28;
-        buf_string charset buf s1; buf_string charset buf s2
+        buf_string buf s1; buf_string buf s2
     | Command string -> buf_opcode buf 29;
-        buf_string charset buf string
+        buf_string buf string
     | Preview  int -> buf_opcode buf 30;
         buf_int buf int
     | ConnectFriend  int -> buf_opcode buf 31;
@@ -992,7 +1000,7 @@
         buf_int buf int
     | SendMessage (int, room_message) -> buf_opcode buf 39;
         buf_int buf int;
-        buf_message charset buf room_message
+        buf_message buf room_message
     | EnableNetwork (int, bool) -> buf_opcode buf 40;
         buf_int buf int; buf_bool buf bool
     
@@ -1003,11 +1011,11 @@
         let protocol = proto.(43) in
         if protocol < 3 then
 (* On previous GUIs, this was done like that ! *)
-          from_gui proto charset buf (SendMessage (-1, PrivateMessage(c,m)))
+          from_gui proto buf (SendMessage (-1, PrivateMessage(c,m)))
         else begin
             buf_opcode buf 43 ;
             buf_int buf c;
-            buf_string charset buf m
+            buf_string buf m
           end
 
 (* These messages are not supported by the core with the provided 
@@ -1055,7 +1063,7 @@
         ) list
     
     | RenameFile (num, new_name) ->
-        buf_opcode buf 56; buf_int buf num; buf_string charset buf new_name
+        buf_opcode buf 56; buf_int buf num; buf_string buf new_name
 
     | GetUploaders -> buf_opcode buf 57 
     | GetPending -> buf_opcode buf 58
@@ -1063,7 +1071,7 @@
     | GetSearch search_id -> buf_opcode buf 60; buf_int buf search_id
     | ConnectClient c -> buf_opcode buf 61; buf_int buf c
     | DisconnectClient c -> buf_opcode buf 62; buf_int buf c
-    | NetworkMessage (n, s) -> buf_opcode buf 63; buf_int buf n; buf_string charset buf s
+    | NetworkMessage (n, s) -> buf_opcode buf 63; buf_int buf n; buf_string buf s
     | GiftAttach _ -> assert false
     | GiftStats -> assert false
         
@@ -1129,9 +1137,9 @@
   for best_gui_version = best_gui_version downto 20 do
 (*     lprintf "best_gui_version: %d\n" best_gui_version; *)
     let proto = Array.create (to_gui_last_opcode+1) best_gui_version in
-    let to_gui = to_gui proto (fun s -> s) in
+    let to_gui = to_gui proto in
     let check_to_gui = 
-      check to_gui (GuiDecoding.to_gui proto (fun s -> s)) in
+      check to_gui (GuiDecoding.to_gui proto) in
     assert (check_to_gui (MessageFromClient (32, "Hello")));
 (*  assert (check_to_gui (File_info file_info_test));  *)
     assert (check_to_gui (DownloadFiles [file_info_test]));
@@ -1146,7 +1154,7 @@
   assert (check_to_gui (Add_plugin_option ("section", "message", "option", StringEntry )));
 *)  
     let check_from_gui = 
-      check ( from_gui proto (fun s -> s) )  (GuiDecoding.from_gui proto (fun s->s)) in
+      check (from_gui proto)  (GuiDecoding.from_gui proto) in
     assert (check_from_gui (MessageToClient (33, "Bye")));
     assert (check_from_gui (GuiExtensions [1, true; 2, false]));
     assert (check_from_gui GetConnectedServers);
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/common/guiEncoding.mli ./src/daemon/common/guiEncoding.mli
--- ./src/daemon/common/guiEncoding.mli	2005-03-20 02:41:29.000000000 +0100
+++ ./src/daemon/common/guiEncoding.mli	2005-04-04 22:34:51.000000000 +0200
@@ -19,6 +19,6 @@
 
 
 val gui_send : (Buffer.t -> 'a -> 'b) -> TcpBufferedSocket.t -> 'a -> unit
-val from_gui : int array -> ( string -> string ) -> Buffer.t -> GuiProto.from_gui -> unit
-val to_gui : int array -> ( string -> string ) -> Buffer.t -> GuiProto.to_gui -> unit
+val from_gui : int array -> Buffer.t -> GuiProto.from_gui -> unit
+val to_gui : int array -> Buffer.t -> GuiProto.to_gui -> unit
   
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/daemon/driver/driverInterface.ml ./src/daemon/driver/driverInterface.ml
--- ./src/daemon/driver/driverInterface.ml	2005-03-20 02:41:29.000000000 +0100
+++ ./src/daemon/driver/driverInterface.ml	2005-04-04 22:34:51.000000000 +0200
@@ -42,10 +42,6 @@
 open CommonGlobals
   
 module P = GuiProto
-  
-let charset_to_gui s = s
-
-let charset_from_gui s = s
 
 let binary_gui_send gui t =
   match gui.gui_sock with
@@ -53,7 +49,7 @@
       Fifo.put core_gui_fifo t
   | Some sock ->
       try
-        GuiEncoding.gui_send (GuiEncoding.to_gui gui.gui_proto_to_gui_version charset_to_gui ) 
+        GuiEncoding.gui_send (GuiEncoding.to_gui gui.gui_proto_to_gui_version) 
         sock t
       with UnsupportedGuiMessage -> 
 (* the message is probably not supported by this GUI *)
@@ -1116,8 +1112,7 @@
         TcpBufferedSocket.set_reader sock (GuiDecoding.gui_cut_messages
             (fun opcode s ->
               try
-                let m = GuiDecoding.from_gui gui.gui_proto_from_gui_version
-                charset_from_gui opcode s in
+                let m = GuiDecoding.from_gui gui.gui_proto_from_gui_version opcode s in
                 gui_reader gui m sock;
               with GuiDecoding.FromGuiMessageNotImplemented -> ()
           ));
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/gtk2/gui/guiCom.ml ./src/gtk2/gui/guiCom.ml
--- ./src/gtk2/gui/guiCom.ml	2005-03-20 02:41:29.000000000 +0100
+++ ./src/gtk2/gui/guiCom.ml	2005-04-04 22:34:51.000000000 +0200
@@ -69,7 +69,7 @@
     None -> 
       lprintf "Message not sent since not connected\n";
   | Some sock ->
-      GuiEncoding.gui_send (GuiEncoding.from_gui from_gui_protocol_used (Glib.Convert.convert ~to_codeset:"ISO-8859-1" ~from_codeset:"UTF-8") ) sock t
+      GuiEncoding.gui_send (GuiEncoding.from_gui from_gui_protocol_used) sock t
           
 let reconnect (gui : gui) value_reader arg reason =
   (try disconnect gui reason with _ -> ());
@@ -132,7 +132,7 @@
       GuiDecoding.gui_cut_messages
         (fun opcode s ->
           try
-            let m = GuiDecoding.to_gui to_gui_protocol_used (Glib.Convert.convert ~to_codeset:"UTF-8" ~from_codeset:"ISO-8859-1") opcode s in
+            let m = GuiDecoding.to_gui to_gui_protocol_used opcode s in
             value_reader arg m;
           with e ->
               lprintf "Exception %s in decode/exec\n" (Printexc2.to_string e); 
@@ -220,7 +220,7 @@
                 BASIC_EVENT (RTIMEOUT) -> close sock Closed_for_timeout
               | _ -> ()
           ) in
-        GuiEncoding.gui_send (GuiEncoding.from_gui from_gui_protocol_used (Glib.Convert.convert ~to_codeset:"ISO-8859-1" ~from_codeset:"UTF-8") ) sock 
+        GuiEncoding.gui_send (GuiEncoding.from_gui from_gui_protocol_used) sock 
           (GuiProto.GuiProtocol GuiProto.best_gui_version);
         set_closer sock (fun _ _ -> 
             scan_port next (i+1) max);
@@ -231,9 +231,7 @@
             GuiDecoding.gui_cut_messages
               (fun opcode s ->
                 try
-                  let m = GuiDecoding.to_gui to_gui_protocol_used
-                      (Glib.Convert.convert ~to_codeset:"UTF-8"
-		                  ~from_codeset:"ISO-8859-1") opcode s in
+                  let m = GuiDecoding.to_gui to_gui_protocol_used opcode s in
                   match m with
                     CoreProtocol (n, _, _) -> 
                       lprintf "GUI version %d on port %d" n i;
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/utils/lib/charset.ml ./src/utils/lib/charset.ml
--- ./src/utils/lib/charset.ml	1970-01-01 01:00:00.000000000 +0100
+++ ./src/utils/lib/charset.ml	2005-04-04 22:34:51.000000000 +0200
@@ -0,0 +1,1638 @@
+(* Copyright 2005 b8_bavard, INRIA *)
+(*
+    This file is part of mldonkey.
+
+    mldonkey is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    mldonkey is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mldonkey; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*)
+
+(*
+ * This part has been inspired by the debian document "Introduction to i18n":
+ * http://www.debian.org/doc/manuals/intro-i18n/
+ * 
+ *)
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          types                                                 *)
+(*                                                                                *)
+(**********************************************************************************)
+
+type charset =
+| ANSI_X3_4_1968 | ANSI_X3_4_1986 | ASCII | CP367 | IBM367 | ISO_IR_6 | ISO646_US | ISO_646_IRV_1991 | US | US_ASCII | CSASCII
+| UTF_8
+| ISO_10646_UCS_2 | UCS_2 | CSUNICODE
+| UCS_2BE | UNICODE_1_1 | UNICODEBIG | CSUNICODE11
+| UCS_2LE | UNICODELITTLE
+| ISO_10646_UCS_4 | UCS_4 | CSUCS4
+| UCS_4BE
+| UCS_4LE
+| UTF_16
+| UTF_16BE
+| UTF_16LE
+| UTF_32
+| UTF_32BE
+| UTF_32LE
+| UNICODE_1_1_UTF_7 | UTF_7 | CSUNICODE11UTF7
+| UCS_2_INTERNAL
+| UCS_2_SWAPPED
+| UCS_4_INTERNAL
+| UCS_4_SWAPPED
+| C99
+| JAVA
+| CP819 | IBM819 | ISO_8859_1 | ISO_IR_100 | ISO8859_1 | ISO_8859_1_1987 | L1 | LATIN1 | CSISOLATIN1
+| ISO_8859_2 | ISO_IR_101 | ISO8859_2 | ISO_8859_2_1987 | L2 | LATIN2 | CSISOLATIN2
+| ISO_8859_3 | ISO_IR_109 | ISO8859_3 | ISO_8859_3_1988 | L3 | LATIN3 | CSISOLATIN3
+| ISO_8859_4 | ISO_IR_110 | ISO8859_4 | ISO_8859_4_1988 | L4 | LATIN4 | CSISOLATIN4
+| CYRILLIC | ISO_8859_5 | ISO_IR_144  | ISO8859_5 | ISO_8859_5_1988 | CSISOLATINCYRILLIC
+| ARABIC | ASMO_708 | ECMA_114 | ISO_8859_6 | ISO_IR_127 | ISO8859_6 | ISO_8859_6_1987 | CSISOLATINARABIC
+| ECMA_118 | ELOT_928 | GREEK | GREEK8 | ISO_8859_7 | ISO_IR_126 | ISO8859_7 | ISO_8859_7_1987 | CSISOLATINGREEK
+| HEBREW | ISO_8859_8 | ISO_IR_138 | ISO8859_8 | ISO_8859_8_1988 | CSISOLATINHEBREW
+| ISO_8859_9 | ISO_IR_148 | ISO8859_9 | ISO_8859_9_1989 | L5 | LATIN5 | CSISOLATIN5
+| ISO_8859_10 | ISO_IR_157 | ISO8859_10 | ISO_8859_10_1992 | L6 | LATIN6 | CSISOLATIN6
+| ISO_8859_13 | ISO_IR_179 | ISO8859_13 | L7 | LATIN7
+| ISO_8859_14 | ISO_CELTIC | ISO8859_14 | ISO_IR_199 | ISO_8859_14_1998 | L8 | LATIN8
+| ISO_8859_15 | ISO_IR_203 | ISO8859_15 | ISO_8859_15_1998
+| ISO_8859_16 | ISO_IR_226 | ISO8859_16 | ISO_8859_16_2000
+| KOI8_R | CSKOI8R
+| KOI8_U
+| KOI8_RU
+| CP1250 | MS_EE | WINDOWS_1250
+| CP1251 | MS_CYRL | WINDOWS_1251
+| CP1252 | MS_ANSI | WINDOWS_1252
+| CP1253 | MS_GREEK | WINDOWS_1253
+| CP1254 | MS_TURK | WINDOWS_1254
+| CP1255 | MS_HEBR | WINDOWS_1255
+| CP1256 | MS_ARAB | WINDOWS_1256
+| CP1257 | WINBALTRIM | WINDOWS_1257
+| CP1258 | WINDOWS_1258
+| I_850 | CP850 | IBM850 | CSPC850MULTILINGUAL
+| I_862 | CP862 | IBM862 | CSPC862LATINHEBREW
+| I_866 | CP866 | IBM866 | CSIBM866
+| MAC | MACINTOSH | MACROMAN | CSMACINTOSH
+| MACCENTRALEUROPE
+| MACICELAND
+| MACCROATIAN
+| MACROMANIA
+| MACCYRILLIC
+| MACUKRAINE
+| MACGREEK
+| MACTURKISH
+| MACHEBREW
+| MACARABIC
+| MACTHAI
+| HP_ROMAN8 | R8 | ROMAN8 | CSHPROMAN8
+| NEXTSTEP
+| ARMSCII_8
+| GEORGIAN_ACADEMY
+| GEORGIAN_PS
+| KOI8_T
+| MULELAO_1
+| CP1133 | IBM_CP1133
+| ISO_IR_166 | TIS_620 | TIS620 | TIS620_0 | TIS620_2529_1 | TIS620_2533_0 | TIS620_2533_1
+| CP874 | WINDOWS_874
+| VISCII | VISCII1_1_1 | CSVISCII
+| TCVN | TCVN_5712 | TCVN5712_1 | TCVN5712_1_1993
+| ISO_IR_14 | ISO646_JP | JIS_C6220_1969_RO | JP | CSISO14JISC6220RO
+| JISX0201_1976 | JIS_X0201 | X0201 | CSHALFWIDTHKATAKANA
+| ISO_IR_87 | JIS0208 | JIS_C6226_1983 | JIS_X0208 | JIS_X0208_1983 | JIS_X0208_1990 | X0208 | CSISO87JISX0208
+| ISO_IR_159 | JIS_X0212 | JIS_X0212_1990 | JIS_X0212_1990_0 | X0212 | CSISO159JISX02121990
+| CN | GB_1988_80 | ISO_IR_57 | ISO646_CN | CSISO57GB1988
+| CHINESE | GB_2312_80 | ISO_IR_58 | CSISO58GB231280
+| CN_GB_ISOIR165 | ISO_IR_165
+| ISO_IR_149 | KOREAN | KSC_5601 | KS_C_5601_1987 | KS_C_5601_1989 | CSKSC56011987
+| EUC_JP | EUCJP | EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE | CSEUCPKDFMTJAPANESE
+| MS_KANJI | SHIFT_JIS | SJIS | CSSHIFTJIS
+| CP932
+| ISO_2022_JP | CSISO2022JP
+| ISO_2022_JP_1
+| ISO_2022_JP_2 | CSISO2022JP2
+| CN_GB | EUC_CN | EUCCN | GB2312 | CSGB2312
+| CP936 | GBK
+| GB18030
+| ISO_2022_CN | CSISO2022CN
+| ISO_2022_CN_EXT
+| HZ | HZ_GB_2312
+| EUC_TW | EUCTW | CSEUCTW
+| BIG_5 | BIG_FIVE | BIG5 | BIGFIVE | CN_BIG5 | CSBIG5
+| CP950
+| BIG5_HKSCS | BIG5HKSCS
+| EUC_KR | EUCKR | CSEUCKR
+| CP949 | UHC
+| CP1361 | JOHAB
+| ISO_2022_KR | CSISO2022KR
+| I_437 | CP437 | IBM437 | CSPC8CODEPAGE437
+| CP737
+| CP775 | IBM775 | CSPC775BALTIC
+| I_852 | CP852 | IBM852 | CSPCP852
+| CP853
+| I_855 | CP855 | IBM855 | CSIBM855
+| I_857 | CP857 | IBM857 | CSIBM857
+| CP858
+| I_860 | CP860 | IBM860 | CSIBM860
+| I_861 | CP_IS | CP861 | IBM861 | CSIBM861
+| I_863 | CP863 | IBM863 | CSIBM863
+| CP864 | IBM864 | CSIBM864
+| I_865 | CP865 | IBM865 | CSIBM865
+| I_869 | CP_GR | CP869 | IBM869 | CSIBM869
+| CP1125
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          charsetstubs                                          *)
+(*                                                                                *)
+(**********************************************************************************)
+
+exception CharsetError
+
+let () = Callback.register_exception "charset_error" CharsetError
+
+external get_charset : unit -> string = "ml_locale_charset"
+external convert_string : string -> string -> string -> string = "ml_convert_string"
+external is_utf8 : string -> bool = "ml_utf8_validate"
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          charset_to_string                                     *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let charset_to_string charset =
+  match charset with
+    | ANSI_X3_4_1968 -> "ANSI_X3.4-1968"
+    | ANSI_X3_4_1986 -> "ANSI_X3.4-1986"
+    | ASCII -> "ASCII"
+    | CP367 -> "CP367"
+    | IBM367 -> "IBM367"
+    | ISO_IR_6 -> "ISO-IR-6"
+    | ISO646_US -> "ISO646-US"
+    | ISO_646_IRV_1991 -> "ISO_646.IRV:1991"
+    | US -> "US"
+    | US_ASCII -> "US-ASCII"
+    | CSASCII -> "CSASCII"
+
+    | UTF_8 -> "UTF-8"
+
+    | ISO_10646_UCS_2 -> "ISO-10646-UCS-2"
+    | UCS_2 -> "UCS-2"
+    | CSUNICODE -> "CSUNICODE"
+
+    | UCS_2BE -> "UCS-2BE"
+    | UNICODE_1_1 -> "UNICODE-1-1"
+    | UNICODEBIG -> "UNICODEBIG"
+    | CSUNICODE11 -> "CSUNICODE11"
+
+    | UCS_2LE -> "UCS-2LE"
+    | UNICODELITTLE -> "UNICODELITTLE"
+
+    | ISO_10646_UCS_4 -> "ISO-10646-UCS-4"
+    | UCS_4 -> "UCS-4"
+    | CSUCS4 -> "CSUCS4"
+
+    | UCS_4BE -> "UCS-4BE"
+
+    | UCS_4LE -> "UCS-4LE"
+
+    | UTF_16 -> "UTF-16"
+
+    | UTF_16BE -> "UTF-16BE"
+
+    | UTF_16LE -> "UTF-16LE"
+
+    | UTF_32 -> "UTF-32"
+
+    | UTF_32BE -> "UTF-32BE"
+
+    | UTF_32LE -> "UTF-32LE"
+
+    | UNICODE_1_1_UTF_7 -> "UNICODE-1-1-UTF-7"
+    | UTF_7 -> "UTF-7"
+    | CSUNICODE11UTF7 -> "CSUNICODE11UTF7"
+
+    | UCS_2_INTERNAL -> "UCS-2-INTERNAL"
+
+    | UCS_2_SWAPPED -> "UCS-2-SWAPPED"
+
+    | UCS_4_INTERNAL -> "UCS-4-INTERNAL"
+
+    | UCS_4_SWAPPED -> "UCS-4-SWAPPED"
+
+    | C99 -> "C99"
+
+    | JAVA -> "JAVA"
+
+    | CP819 -> "CP819"
+    | IBM819 -> "IBM819"
+    | ISO_8859_1 -> "ISO-8859-1"
+    | ISO_IR_100 -> "ISO-IR-100"
+    | ISO8859_1 -> "ISO8859-1"
+    | ISO_8859_1_1987 -> "ISO_8859-1:1987"
+    | L1 -> "L1"
+    | LATIN1 -> "LATIN1"
+    | CSISOLATIN1 -> "CSISOLATIN1"
+
+    | ISO_8859_2 -> "ISO-8859-2"
+    | ISO_IR_101 -> "ISO-IR-101"
+    | ISO8859_2 -> "ISO8859-2"
+    | ISO_8859_2_1987 -> "ISO_8859-2:1987"
+    | L2 -> "L2"
+    | LATIN2 -> "LATIN2"
+    | CSISOLATIN2 -> "CSISOLATIN2"
+
+    | ISO_8859_3 -> "ISO-8859-3"
+    | ISO_IR_109 -> "ISO-IR-109"
+    | ISO8859_3 -> "ISO8859-3"
+    | ISO_8859_3_1988 -> "ISO_8859-3:1988"
+    | L3 -> "L3"
+    | LATIN3 -> "LATIN3"
+    | CSISOLATIN3 -> "CSISOLATIN3"
+
+    | ISO_8859_4 -> "ISO-8859-4"
+    | ISO_IR_110 -> "ISO-IR-110"
+    | ISO8859_4 -> "ISO8859-4"
+    | ISO_8859_4_1988 -> "ISO_8859-4:1988"
+    | L4 -> "L4"
+    | LATIN4 -> "LATIN4"
+    | CSISOLATIN4 -> "CSISOLATIN4"
+
+    | CYRILLIC -> "CYRILLIC"
+    | ISO_8859_5 -> "ISO-8859-5"
+    | ISO_IR_144 -> "ISO-IR-144"
+    | ISO8859_5 -> "ISO8859-5"
+    | ISO_8859_5_1988 -> "ISO_8859-5:1988"
+    | CSISOLATINCYRILLIC -> "CSISOLATINCYRILLIC"
+
+    | ARABIC -> "ARABIC"
+    | ASMO_708 -> "ASMO-708"
+    | ECMA_114 -> "ECMA-114"
+    | ISO_8859_6 -> "ISO-8859-6"
+    | ISO_IR_127 -> "ISO-IR-127"
+    | ISO8859_6 -> "ISO8859-6"
+    | ISO_8859_6_1987 -> "ISO_8859-6:1987"
+    | CSISOLATINARABIC -> "CSISOLATINARABIC"
+
+    | ECMA_118 -> "ECMA-118"
+    | ELOT_928 -> "ELOT_928"
+    | GREEK -> "GREEK"
+    | GREEK8 -> "GREEK8"
+    | ISO_8859_7 -> "ISO-8859-7"
+    | ISO_IR_126 -> "ISO-IR-126"
+    | ISO8859_7 -> "ISO8859-7"
+    | ISO_8859_7_1987 -> "ISO_8859-7:1987"
+    | CSISOLATINGREEK -> "CSISOLATINGREEK"
+
+    | HEBREW -> "HEBREW"
+    | ISO_8859_8 -> "ISO-8859-8"
+    | ISO_IR_138 -> "ISO-IR-138"
+    | ISO8859_8 -> "ISO8859-8"
+    | ISO_8859_8_1988 -> "ISO_8859-8:1988"
+    | CSISOLATINHEBREW -> "CSISOLATINHEBREW"
+
+    | ISO_8859_9 -> "ISO-8859-9"
+    | ISO_IR_148 -> "ISO-IR-148"
+    | ISO8859_9 -> "ISO8859-9"
+    | ISO_8859_9_1989 -> "ISO_8859-9:1989"
+    | L5 -> "L5"
+    | LATIN5 -> "LATIN5"
+    | CSISOLATIN5 -> "CSISOLATIN5"
+
+    | ISO_8859_10 -> "ISO-8859-10"
+    | ISO_IR_157 -> "ISO-IR-157"
+    | ISO8859_10 -> "ISO8859-10"
+    | ISO_8859_10_1992 -> "ISO_8859-10:1992"
+    | L6 -> "L6"
+    | LATIN6 -> "LATIN6"
+    | CSISOLATIN6 -> "CSISOLATIN6"
+
+    | ISO_8859_13 -> "ISO-8859-13"
+    | ISO_IR_179 -> "ISO-IR-179"
+    | ISO8859_13 -> "ISO8859-13"
+    | L7 -> "L7"
+    | LATIN7 -> "LATIN7"
+
+    | ISO_8859_14 -> "ISO-8859-14"
+    | ISO_CELTIC -> "ISO-CELTIC"
+    | ISO_IR_199 -> "ISO-IR-199"
+    | ISO8859_14 -> "ISO8859-14"
+    | ISO_8859_14_1998 -> "ISO_8859-14:1998"
+    | L8 -> "L8"
+    | LATIN8 -> "LATIN8"
+
+    | ISO_8859_15 -> "ISO-8859-15"
+    | ISO_IR_203 -> "ISO-IR-203"
+    | ISO8859_15 -> "ISO8859-15"
+    | ISO_8859_15_1998 -> "ISO_8859-15:1998"
+
+    | ISO_8859_16 -> "ISO-8859-16"
+    | ISO_IR_226 -> "ISO-IR-226"
+    | ISO8859_16 -> "ISO8859-16"
+    | ISO_8859_16_2000 -> "ISO_8859-16:2000"
+
+    | KOI8_R -> "KOI8-R"
+    | CSKOI8R -> "CSKOI8R"
+
+    | KOI8_U -> "KOI8-U"
+
+    | KOI8_RU -> "KOI8-RU"
+
+    | CP1250 -> "CP1250"
+    | MS_EE -> "MS-EE"
+    | WINDOWS_1250 -> "WINDOWS-1250"
+
+    | CP1251 -> "CP1251"
+    | MS_CYRL -> "MS-CYRL"
+    | WINDOWS_1251 -> "WINDOWS-1251"
+
+    | CP1252 -> "CP1252"
+    | MS_ANSI -> "MS-ANSI"
+    | WINDOWS_1252 -> "WINDOWS-1252"
+
+    | CP1253 -> "CP1253"
+    | MS_GREEK -> "MS-GREEK"
+    | WINDOWS_1253 -> "WINDOWS-1253"
+
+    | CP1254 -> "CP1254"
+    | MS_TURK -> "MS-TURK"
+    | WINDOWS_1254 -> "WINDOWS-1254"
+
+    | CP1255 -> "CP1255"
+    | MS_HEBR -> "MS-HEBR"
+    | WINDOWS_1255 -> "WINDOWS-1255"
+
+    | CP1256 -> "CP1256"
+    | MS_ARAB -> "MS-ARAB"
+    | WINDOWS_1256 -> "WINDOWS-1256"
+
+    | CP1257 -> "CP1257"
+    | WINBALTRIM -> "WINBALTRIM"
+    | WINDOWS_1257 -> "WINDOWS-1257"
+
+    | CP1258 -> "CP1258"
+    | WINDOWS_1258 -> "WINDOWS-1258"
+
+    | I_850 -> "850"
+    | CP850 -> "CP850"
+    | IBM850 -> "IBM850"
+    | CSPC850MULTILINGUAL -> "CSPC850MULTILINGUAL"
+
+    | I_862 -> "862"
+    | CP862 -> "CP862"
+    | IBM862 -> "IBM862"
+    | CSPC862LATINHEBREW -> "CSPC862LATINHEBREW"
+
+    | I_866 -> "866"
+    | CP866 -> "CP866"
+    | IBM866 -> "IBM866"
+    | CSIBM866 -> "CSIBM866"
+
+    | MAC -> "MAC"
+    | MACINTOSH -> "MACINTOSH"
+    | MACROMAN -> "MACROMAN"
+    | CSMACINTOSH -> "CSMACINTOSH"
+
+    | MACCENTRALEUROPE -> "MACCENTRALEUROPE"
+
+    | MACICELAND -> "MACICELAND"
+
+    | MACCROATIAN -> "MACCROATIAN"
+
+    | MACROMANIA -> "MACROMANIA"
+
+    | MACCYRILLIC -> "MACCYRILLIC"
+
+    | MACUKRAINE -> "MACUKRAINE"
+
+    | MACGREEK -> "MACGREEK"
+
+    | MACTURKISH -> "MACTURKISH"
+
+    | MACHEBREW -> "MACHEBREW"
+
+    | MACARABIC -> "MACARABIC"
+
+    | MACTHAI -> "MACTHAI"
+
+    | HP_ROMAN8 -> "HP-ROMAN8"
+    | R8 -> "R8"
+    | ROMAN8 -> "ROMAN8"
+    | CSHPROMAN8 -> "CSHPROMAN8"
+
+    | NEXTSTEP -> "NEXTSTEP"
+
+    | ARMSCII_8 -> "ARMSCII-8"
+
+    | GEORGIAN_ACADEMY -> "GEORGIAN-ACADEMY"
+
+    | GEORGIAN_PS -> "GEORGIAN-PS"
+
+    | KOI8_T -> "KOI8-T"
+
+    | MULELAO_1 -> "MULELAO-1"
+
+    | CP1133 -> "CP1133"
+    | IBM_CP1133 -> "IBM-CP1133"
+
+    | ISO_IR_166 -> "ISO-IR-166"
+    | TIS_620 -> "TIS-620"
+    | TIS620 -> "TIS620"
+    | TIS620_0 -> "TIS620-0"
+    | TIS620_2529_1 -> "TIS620.2529-1"
+    | TIS620_2533_0 -> "TIS620.2533-0"
+    | TIS620_2533_1 -> "TIS620.2533-1"
+
+    | CP874 -> "CP874"
+    | WINDOWS_874 -> "WINDOWS-874"
+
+    | VISCII -> "VISCII"
+    | VISCII1_1_1 -> "VISCII1.1-1"
+    | CSVISCII -> "CSVISCII"
+
+    | TCVN -> "TCVN"
+    | TCVN_5712 -> "TCVN-5712"
+    | TCVN5712_1 -> "TCVN5712-1"
+    | TCVN5712_1_1993 -> "TCVN5712-1:1993"
+
+    | ISO_IR_14 -> "ISO-IR-14"
+    | ISO646_JP -> "ISO646-JP"
+    | JIS_C6220_1969_RO -> "JIS_C6220-1969-RO"
+    | JP -> "JP"
+    | CSISO14JISC6220RO -> "CSISO14JISC6220RO"
+
+    | JISX0201_1976 -> "JISX0201-1976"
+    | JIS_X0201 -> "JIS_X0201"
+    | X0201 -> "X0201"
+    | CSHALFWIDTHKATAKANA -> "CSHALFWIDTHKATAKANA"
+
+    | ISO_IR_87 -> "ISO-IR-87"
+    | JIS0208 -> "JIS0208"
+    | JIS_C6226_1983 -> "JIS_C6226-1983"
+    | JIS_X0208 -> "JIS_X0208"
+    | JIS_X0208_1983 -> "JIS_X0208-1983"
+    | JIS_X0208_1990 -> "JIS_X0208-1990"
+    | X0208 -> "X0208"
+    | CSISO87JISX0208 -> "CSISO87JISX0208"
+
+    | ISO_IR_159 -> "ISO-IR-159"
+    | JIS_X0212 -> "JIS_X0212"
+    | JIS_X0212_1990 -> "JIS_X0212-1990"
+    | JIS_X0212_1990_0 -> "JIS_X0212.1990-0"
+    | X0212 -> "X0212"
+    | CSISO159JISX02121990 -> "CSISO159JISX02121990"
+
+    | CN -> "CN"
+    | GB_1988_80 -> "GB_1988-80"
+    | ISO_IR_57 -> "ISO-IR-57"
+    | ISO646_CN -> "ISO646-CN"
+    | CSISO57GB1988 -> "CSISO57GB1988"
+
+    | CHINESE -> "CHINESE"
+    | GB_2312_80 -> "GB_2312-80"
+    | ISO_IR_58 -> "ISO-IR-58"
+    | CSISO58GB231280 -> "CSISO58GB231280"
+
+    | CN_GB_ISOIR165 -> "CN-GB-ISOIR165"
+    | ISO_IR_165 -> "ISO-IR-165"
+
+    | ISO_IR_149 -> "ISO-IR-149"
+    | KOREAN -> "KOREAN"
+    | KSC_5601 -> "KSC_5601"
+    | KS_C_5601_1987 -> "KS_C_5601-1987"
+    | KS_C_5601_1989 -> "KS_C_5601-1989"
+    | CSKSC56011987 -> "CSKSC56011987"
+
+    | EUC_JP -> "EUC-JP"
+    | EUCJP -> "EUCJP"
+    | EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE -> "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE"
+    | CSEUCPKDFMTJAPANESE -> "CSEUCPKDFMTJAPANESE"
+
+    | MS_KANJI -> "MS_KANJI"
+    | SHIFT_JIS -> "SHIFT-JIS"
+    | SJIS -> "SJIS"
+    | CSSHIFTJIS -> "CSSHIFTJIS"
+
+    | CP932 -> "CP932"
+
+    | ISO_2022_JP -> "ISO-2022-JP"
+    | CSISO2022JP -> "CSISO2022JP"
+
+    | ISO_2022_JP_1 -> "ISO-2022-JP-1"
+
+    | ISO_2022_JP_2 -> "ISO-2022-JP-2"
+    | CSISO2022JP2 -> "CSISO2022JP2"
+
+    | CN_GB -> "CN-GB"
+    | EUC_CN -> "EUC-CN"
+    | EUCCN -> "EUCCN"
+    | GB2312 -> "GB2312"
+    | CSGB2312 -> "CSGB2312"
+
+    | CP936 -> "CP936"
+    | GBK -> "GBK"
+
+    | GB18030 -> "GB18030"
+
+    | ISO_2022_CN -> "ISO-2022-CN"
+    | CSISO2022CN -> "CSISO2022CN"
+
+    | ISO_2022_CN_EXT -> "ISO-2022-CN-EXT"
+
+    | HZ -> "HZ"
+    | HZ_GB_2312 -> "HZ-GB-2312"
+
+    | EUC_TW -> "EUC-TW"
+    | EUCTW -> "EUCTW"
+    | CSEUCTW -> "CSEUCTW"
+
+    | BIG_5 -> "BIG-5"
+    | BIG_FIVE -> "BIG-FIVE"
+    | BIG5 -> "BIG5"
+    | BIGFIVE -> "BIGFIVE"
+    | CN_BIG5 -> "CN-BIG5"
+    | CSBIG5 -> "CSBIG5"
+
+    | CP950 -> "CP950"
+
+    | BIG5_HKSCS -> "BIG5-HKSCS"
+    | BIG5HKSCS -> "BIG5HKSCS"
+
+    | EUC_KR -> "EUC-KR"
+    | EUCKR -> "EUCKR"
+    | CSEUCKR -> "CSEUCKR"
+
+    | CP949 -> "CP949"
+    | UHC -> "UHC"
+
+    | CP1361 -> "CP1361"
+    | JOHAB -> "JOHAB"
+
+    | ISO_2022_KR -> "ISO-2022-KR"
+    | CSISO2022KR -> "CSISO2022KR"
+
+    | I_437 -> "437"
+    | CP437 -> "CP437"
+    | IBM437 -> "IBM437"
+    | CSPC8CODEPAGE437 -> "CSPC8CODEPAGE437"
+
+    | CP737 -> "CP737"
+
+    | CP775 -> "CP775"
+    | IBM775 -> "IBM775"
+    | CSPC775BALTIC -> "CSPC775BALTIC"
+
+    | I_852 -> "852"
+    | CP852 -> "CP852"
+    | IBM852 -> "IBM852"
+    | CSPCP852 -> "CSPCP852"
+
+    | CP853 -> "CP853"
+
+    | I_855 -> "855"
+    | CP855 -> "CP855"
+    | IBM855 -> "IBM855"
+    | CSIBM855 -> "CSIBM855"
+
+    | I_857 -> "857"
+    | CP857 -> "CP857"
+    | IBM857 -> "IBM857"
+    | CSIBM857 -> "CSIBM857"
+
+    | CP858 -> "CP858"
+
+    | I_860 -> "860"
+    | CP860 -> "CP860"
+    | IBM860 -> "IBM860"
+    | CSIBM860 -> "CSIBM860"
+
+    | I_861 -> "861"
+    | CP_IS -> "CP-IS"
+    | CP861 -> "CP861"
+    | IBM861 -> "IBM861"
+    | CSIBM861 -> "CSIBM861"
+
+    | I_863 -> "863"
+    | CP863 -> "CP863"
+    | IBM863 -> "IBM863"
+    | CSIBM863 -> "CSIBM863"
+
+    | CP864 -> "CP864"
+    | IBM864 -> "IBM864"
+    | CSIBM864 -> "CSIBM864"
+
+    | I_865 -> "865"
+    | CP865 -> "CP865"
+    | IBM865 -> "IBM865"
+    | CSIBM865 -> "CSIBM865"
+
+    | I_869 -> "869"
+    | CP_GR -> "CP-GR"
+    | CP869 -> "CP869"
+    | IBM869 -> "IBM869"
+    | CSIBM869 -> "CSIBM869"
+
+    | CP1125 -> "CP1125"
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          charset_from_string                                   *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let charset_from_string s =
+  match s with
+    | "ANSI_X3.4-1968" -> ANSI_X3_4_1968
+    | "ANSI_X3.4-1986" -> ANSI_X3_4_1986
+    | "ASCII" -> ASCII
+    | "CP367" -> CP367
+    | "IBM367" -> IBM367
+    | "ISO-IR-6" -> ISO_IR_6
+    | "ISO646-US" -> ISO646_US
+    | "ISO_646.IRV:1991" -> ISO_646_IRV_1991
+    | "US" -> US
+    | "US-ASCII" -> US_ASCII
+    | "CSASCII" -> CSASCII
+
+    | "UTF-8" -> UTF_8
+
+    | "ISO-10646-UCS-2" -> ISO_10646_UCS_2
+    | "UCS-2" -> UCS_2
+    | "CSUNICODE" -> CSUNICODE
+
+    | "UCS-2BE" -> UCS_2BE
+    | "UNICODE-1-1" -> UNICODE_1_1
+    | "UNICODEBIG" -> UNICODEBIG
+    | "CSUNICODE11" -> CSUNICODE11
+
+    | "UCS-2LE" -> UCS_2LE
+    | "UNICODELITTLE" -> UNICODELITTLE
+
+    | "ISO-10646-UCS-4" -> ISO_10646_UCS_4
+    | "UCS-4" -> UCS_4
+    | "CSUCS4" -> CSUCS4
+
+    | "UCS-4BE" -> UCS_4BE
+
+    | "UCS-4LE" -> UCS_4LE
+
+    | "UTF-16" -> UTF_16
+
+    | "UTF-16BE" -> UTF_16BE
+
+    | "UTF-16LE" -> UTF_16LE
+
+    | "UTF-32" -> UTF_32
+
+    | "UTF-32BE" -> UTF_32BE
+
+    | "UTF-32LE" -> UTF_32LE
+
+    | "UNICODE-1-1-UTF-7" -> UNICODE_1_1_UTF_7
+    | "UTF-7" -> UTF_7
+    | "CSUNICODE11UTF7" -> CSUNICODE11UTF7
+
+    | "UCS-2-INTERNAL" -> UCS_2_INTERNAL
+
+    | "UCS-2-SWAPPED" -> UCS_2_SWAPPED
+
+    | "UCS-4-INTERNAL" -> UCS_4_INTERNAL
+
+    | "UCS-4-SWAPPED" -> UCS_4_SWAPPED
+
+    | "C99" -> C99
+
+    | "JAVA" -> JAVA
+
+    | "CP819" -> CP819
+    | "IBM819" -> IBM819
+    | "ISO-8859-1" -> ISO_8859_1
+    | "ISO-IR-100" -> ISO_IR_100
+    | "ISO8859-1" -> ISO8859_1
+    | "ISO_8859-1" -> ISO_8859_1
+    | "ISO_8859-1:1987" -> ISO_8859_1_1987
+    | "L1" -> L1
+    | "LATIN1" -> LATIN1
+    | "CSISOLATIN1" -> CSISOLATIN1
+
+    | "ISO-8859-2" -> ISO_8859_2
+    | "ISO-IR-101" -> ISO_IR_101
+    | "ISO8859-2" -> ISO8859_2
+    | "ISO_8859-2" -> ISO_8859_2
+    | "ISO_8859-2:1987" -> ISO_8859_2_1987
+    | "L2" -> L2
+    | "LATIN2" -> LATIN2
+    | "CSISOLATIN2" -> CSISOLATIN2
+
+    | "ISO-8859-3" -> ISO_8859_3
+    | "ISO-IR-109" -> ISO_IR_109
+    | "ISO8859-3" -> ISO8859_3
+    | "ISO_8859-3" -> ISO_8859_3
+    | "ISO_8859-3:1988" -> ISO_8859_3_1988
+    | "L3" -> L3
+    | "LATIN3" -> LATIN3
+    | "CSISOLATIN3" -> CSISOLATIN3
+
+    | "ISO-8859-4" -> ISO_8859_4
+    | "ISO-IR-110" -> ISO_IR_110
+    | "ISO8859-4" -> ISO8859_4
+    | "ISO_8859-4" -> ISO_8859_4
+    | "ISO_8859-4:1988" -> ISO_8859_4_1988
+    | "L4" -> L4
+    | "LATIN4" -> LATIN4
+    | "CSISOLATIN4" -> CSISOLATIN4
+
+    | "CYRILLIC" -> CYRILLIC
+    | "ISO-8859-5" -> ISO_8859_5
+    | "ISO-IR-144" -> ISO_IR_144
+    | "ISO8859-5" -> ISO8859_5
+    | "ISO_8859-5" -> ISO_8859_5
+    | "ISO_8859-5:1988" -> ISO_8859_5_1988
+    | "CSISOLATINCYRILLIC" -> CSISOLATINCYRILLIC
+
+    | "ARABIC" -> ARABIC
+    | "ASMO-708" -> ASMO_708
+    | "ECMA-114" -> ECMA_114
+    | "ISO-8859-6" -> ISO_8859_6
+    | "ISO-IR-127" -> ISO_IR_127
+    | "ISO8859-6" -> ISO8859_6
+    | "ISO_8859-6" -> ISO_8859_6
+    | "ISO_8859-6:1987" -> ISO_8859_6_1987
+    | "CSISOLATINARABIC" -> CSISOLATINARABIC
+
+    | "ECMA-118" -> ECMA_118
+    | "ELOT_928" -> ELOT_928
+    | "GREEK" -> GREEK
+    | "GREEK8" -> GREEK8
+    | "ISO-8859-7" -> ISO_8859_7
+    | "ISO-IR-126" -> ISO_IR_126
+    | "ISO8859-7" -> ISO8859_7
+    | "ISO_8859-7" -> ISO_8859_7
+    | "ISO_8859-7:1987" -> ISO_8859_7_1987
+    | "CSISOLATINGREEK" -> CSISOLATINGREEK
+
+    | "HEBREW" -> HEBREW
+    | "ISO-8859-8" -> ISO_8859_8
+    | "ISO-IR-138" -> ISO_IR_138
+    | "ISO8859-8" -> ISO8859_8
+    | "ISO_8859-8" -> ISO_8859_8
+    | "ISO_8859-8:1988" -> ISO_8859_8_1988
+    | "CSISOLATINHEBREW" -> CSISOLATINHEBREW
+
+    | "ISO-8859-9" -> ISO_8859_9
+    | "ISO-IR-148" -> ISO_IR_148
+    | "ISO8859-9" -> ISO8859_9
+    | "ISO_8859-9" -> ISO_8859_9
+    | "ISO_8859-9:1989" -> ISO_8859_9_1989
+    | "L5" -> L5
+    | "LATIN5" -> LATIN5
+    | "CSISOLATIN5" -> CSISOLATIN5
+
+    | "ISO-8859-10" -> ISO_8859_10
+    | "ISO-IR-157" -> ISO_IR_157
+    | "ISO8859-10" -> ISO8859_10
+    | "ISO_8859-10" -> ISO_8859_10
+    | "ISO_8859-10:1992" -> ISO_8859_10_1992
+    | "L6" -> L6
+    | "LATIN6" -> LATIN6
+    | "CSISOLATIN6" -> CSISOLATIN6
+
+    | "ISO-8859-13" -> ISO_8859_13
+    | "ISO-IR-179" -> ISO_IR_179
+    | "ISO8859-13" -> ISO8859_13
+    | "ISO_8859-13" -> ISO_8859_13
+    | "L7" -> L7
+    | "LATIN7" -> LATIN7
+
+    | "ISO-8859-14" -> ISO_8859_14
+    | "ISO-CELTIC" -> ISO_CELTIC
+    | "ISO-IR-199" -> ISO_IR_199
+    | "ISO8859-14" -> ISO8859_14
+    | "ISO_8859-14" -> ISO_8859_14
+    | "ISO_8859-14:1998" -> ISO_8859_14_1998
+    | "L8" -> L8
+    | "LATIN8" -> LATIN8
+
+    | "ISO-8859-15" -> ISO_8859_15
+    | "ISO-IR-203" -> ISO_IR_203
+    | "ISO8859-15" -> ISO8859_15
+    | "ISO_8859-15" -> ISO_8859_15
+    | "ISO_8859-15:1998" -> ISO_8859_15_1998
+
+    | "ISO-8859-16" -> ISO_8859_16
+    | "ISO-IR-226" -> ISO_IR_226
+    | "ISO8859-16" -> ISO8859_16
+    | "ISO_8859-16" -> ISO_8859_16
+    | "ISO_8859-16:2000" -> ISO_8859_16_2000
+
+    | "KOI8-R" -> KOI8_R
+    | "CSKOI8R" -> CSKOI8R
+
+    | "KOI8-U" -> KOI8_U
+
+    | "KOI8-RU" -> KOI8_RU
+
+    | "CP1250" -> CP1250
+    | "MS-EE" -> MS_EE
+    | "WINDOWS-1250" -> WINDOWS_1250
+
+    | "CP1251" -> CP1251
+    | "MS-CYRL" -> MS_CYRL
+    | "WINDOWS-1251" -> WINDOWS_1251
+
+    | "CP1252" -> CP1252
+    | "MS-ANSI" -> MS_ANSI
+    | "WINDOWS-1252" -> WINDOWS_1252
+
+    | "CP1253" -> CP1253
+    | "MS-GREEK" -> MS_GREEK
+    | "WINDOWS-1253" -> WINDOWS_1253
+
+    | "CP1254" -> CP1254
+    | "MS-TURK" -> MS_TURK
+    | "WINDOWS-1254" -> WINDOWS_1254
+
+    | "CP1255" -> CP1255
+    | "MS-HEBR" -> MS_HEBR
+    | "WINDOWS-1255" -> WINDOWS_1255
+
+    | "CP1256" -> CP1256
+    | "MS-ARAB" -> MS_ARAB
+    | "WINDOWS-1256" -> WINDOWS_1256
+
+    | "CP1257" -> CP1257
+    | "WINBALTRIM" -> WINBALTRIM
+    | "WINDOWS-1257" -> WINDOWS_1257
+
+    | "CP1258" -> CP1258
+    | "WINDOWS-1258" -> WINDOWS_1258
+
+    | "850" -> I_850
+    | "CP850" -> CP850
+    | "IBM850" -> IBM850
+    | "CSPC850MULTILINGUAL" -> CSPC850MULTILINGUAL
+
+    | "862" -> I_862
+    | "CP862" -> CP862
+    | "IBM862" -> IBM862
+    | "CSPC862LATINHEBREW" -> CSPC862LATINHEBREW
+
+    | "866" -> I_866
+    | "CP866" -> CP866
+    | "IBM866" -> IBM866
+    | "CSIBM866" -> CSIBM866
+
+    | "MAC" -> MAC
+    | "MACINTOSH" -> MACINTOSH
+    | "MACROMAN" -> MACROMAN
+    | "CSMACINTOSH" -> CSMACINTOSH
+
+    | "MACCENTRALEUROPE" -> MACCENTRALEUROPE
+
+    | "MACICELAND" -> MACICELAND
+
+    | "MACCROATIAN" -> MACCROATIAN
+
+    | "MACROMANIA" -> MACROMANIA
+
+    | "MACCYRILLIC" -> MACCYRILLIC
+
+    | "MACUKRAINE" -> MACUKRAINE
+
+    | "MACGREEK" -> MACGREEK
+
+    | "MACTURKISH" -> MACTURKISH
+
+    | "MACHEBREW" -> MACHEBREW
+
+    | "MACARABIC" -> MACARABIC
+
+    | "MACTHAI" -> MACTHAI
+
+    | "HP-ROMAN8" -> HP_ROMAN8
+    | "R8" -> R8
+    | "ROMAN8" -> ROMAN8
+    | "CSHPROMAN8" -> CSHPROMAN8
+
+    | "NEXTSTEP" -> NEXTSTEP
+
+    | "ARMSCII-8" -> ARMSCII_8
+
+    | "GEORGIAN-ACADEMY" -> GEORGIAN_ACADEMY
+
+    | "GEORGIAN-PS" -> GEORGIAN_PS
+
+    | "KOI8-T" -> KOI8_T
+
+    | "MULELAO-1" -> MULELAO_1
+
+    | "CP1133" -> CP1133
+    | "IBM-CP1133" -> IBM_CP1133
+
+    | "ISO-IR-166" -> ISO_IR_166
+    | "TIS-620" -> TIS_620
+    | "TIS620" -> TIS620
+    | "TIS620-0" -> TIS620_0
+    | "TIS620.2529-1" -> TIS620_2529_1
+    | "TIS620.2533-0" -> TIS620_2533_0
+    | "TIS620.2533-1" -> TIS620_2533_1
+
+    | "CP874" -> CP874
+    | "WINDOWS-874" -> WINDOWS_874
+
+    | "VISCII" -> VISCII
+    | "VISCII1.1-1" -> VISCII1_1_1
+    | "CSVISCII" -> CSVISCII
+
+    | "TCVN" -> TCVN
+    | "TCVN-5712" -> TCVN_5712
+    | "TCVN5712-1" -> TCVN5712_1
+    | "TCVN5712-1:1993" -> TCVN5712_1_1993
+
+    | "ISO-IR-14" -> ISO_IR_14
+    | "ISO646-JP" -> ISO646_JP
+    | "JIS_C6220-1969-RO" -> JIS_C6220_1969_RO
+    | "JP" -> JP
+    | "CSISO14JISC6220RO" -> CSISO14JISC6220RO
+
+    | "JISX0201-1976" -> JISX0201_1976
+    | "JIS_X0201" -> JIS_X0201
+    | "X0201" -> X0201
+    | "CSHALFWIDTHKATAKANA" -> CSHALFWIDTHKATAKANA
+
+    | "ISO-IR-87" -> ISO_IR_87
+    | "JIS0208" -> JIS0208
+    | "JIS_C6226-1983" -> JIS_C6226_1983
+    | "JIS_X0208" -> JIS_X0208
+    | "JIS_X0208-1983" -> JIS_X0208_1983
+    | "JIS_X0208-1990" -> JIS_X0208_1990
+    | "X0208" -> X0208
+    | "CSISO87JISX0208" -> CSISO87JISX0208
+
+    | "ISO-IR-159" -> ISO_IR_159
+    | "JIS_X0212" -> JIS_X0212
+    | "JIS_X0212-1990" -> JIS_X0212_1990
+    | "JIS_X0212.1990-0" -> JIS_X0212_1990_0
+    | "X0212" -> X0212
+    | "CSISO159JISX02121990" -> CSISO159JISX02121990
+
+    | "CN" -> CN
+    | "GB_1988-80" -> GB_1988_80
+    | "ISO-IR-57" -> ISO_IR_57
+    | "ISO646-CN" -> ISO646_CN
+    | "CSISO57GB1988" -> CSISO57GB1988
+
+    | "CHINESE" -> CHINESE
+    | "GB_2312-80" -> GB_2312_80
+    | "ISO-IR-58" -> ISO_IR_58
+    | "CSISO58GB231280" -> CSISO58GB231280
+
+    | "CN-GB-ISOIR165" -> CN_GB_ISOIR165
+    | "ISO-IR-165" -> ISO_IR_165
+
+    | "ISO-IR-149" -> ISO_IR_149
+    | "KOREAN" -> KOREAN
+    | "KSC_5601" -> KSC_5601
+    | "KS_C_5601-1987" -> KS_C_5601_1987
+    | "KS_C_5601-1989" -> KS_C_5601_1989
+    | "CSKSC56011987" -> CSKSC56011987
+
+    | "EUC-JP" -> EUC_JP
+    | "EUCJP" -> EUCJP
+    | "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE" -> EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE
+    | "CSEUCPKDFMTJAPANESE" -> CSEUCPKDFMTJAPANESE
+
+    | "MS_KANJI" -> MS_KANJI
+    | "SHIFT-JIS" -> SHIFT_JIS
+    | "SHIFT_JIS" -> SHIFT_JIS
+    | "SJIS" -> SJIS
+    | "CSSHIFTJIS" -> CSSHIFTJIS
+
+    | "CP932" -> CP932
+
+    | "ISO-2022-JP" -> ISO_2022_JP
+    | "CSISO2022JP" -> CSISO2022JP
+
+    | "ISO-2022-JP-1" -> ISO_2022_JP_1
+
+    | "ISO-2022-JP-2" -> ISO_2022_JP_2
+    | "CSISO2022JP2" -> CSISO2022JP2
+
+    | "CN-GB" -> CN_GB
+    | "EUC-CN" -> EUC_CN
+    | "EUCCN" -> EUCCN
+    | "GB2312" -> GB2312
+    | "CSGB2312" -> CSGB2312
+
+    | "CP936" -> CP936
+    | "GBK" -> GBK
+
+    | "GB18030" -> GB18030
+
+    | "ISO-2022-CN" -> ISO_2022_CN
+    | "CSISO2022CN" -> CSISO2022CN
+
+    | "ISO-2022-CN-EXT" -> ISO_2022_CN_EXT
+
+    | "HZ" -> HZ
+    | "HZ-GB-2312" -> HZ_GB_2312
+
+    | "EUC-TW" -> EUC_TW
+    | "EUCTW" -> EUCTW
+    | "CSEUCTW" -> CSEUCTW
+
+    | "BIG-5" -> BIG_5
+    | "BIG-FIVE" -> BIG_FIVE
+    | "BIG5" -> BIG5
+    | "BIGFIVE" -> BIGFIVE
+    | "CN-BIG5" -> CN_BIG5
+    | "CSBIG5" -> CSBIG5
+
+    | "CP950" -> CP950
+
+    | "BIG5-HKSCS" -> BIG5_HKSCS
+    | "BIG5HKSCS" -> BIG5HKSCS
+
+    | "EUC-KR" -> EUC_KR
+    | "EUCKR" -> EUCKR
+    | "CSEUCKR" -> CSEUCKR
+
+    | "CP949" -> CP949
+    | "UHC" -> UHC
+
+    | "CP1361" -> CP1361
+    | "JOHAB" -> JOHAB
+
+    | "ISO-2022-KR" -> ISO_2022_KR
+    | "CSISO2022KR" -> CSISO2022KR
+
+    | "437" -> I_437
+    | "CP437" -> CP437
+    | "IBM437" -> IBM437
+    | "CSPC8CODEPAGE437" -> CSPC8CODEPAGE437
+
+    | "CP737" -> CP737
+
+    | "CP775" -> CP775
+    | "IBM775" -> IBM775
+    | "CSPC775BALTIC" -> CSPC775BALTIC
+
+    | "852" -> I_852
+    | "CP852" -> CP852
+    | "IBM852" -> IBM852
+    | "CSPCP852" -> CSPCP852
+
+    | "CP853" -> CP853
+
+    | "855" -> I_855
+    | "CP855" -> CP855
+    | "IBM855" -> IBM855
+    | "CSIBM855" -> CSIBM855
+
+    | "857" -> I_857
+    | "CP857" -> CP857
+    | "IBM857" -> IBM857
+    | "CSIBM857" -> CSIBM857
+
+    | "CP858" -> CP858
+
+    | "860" -> I_860
+    | "CP860" -> CP860
+    | "IBM860" -> IBM860
+    | "CSIBM860" -> CSIBM860
+
+    | "861" -> I_861
+    | "CP-IS" -> CP_IS
+    | "CP861" -> CP861
+    | "IBM861" -> IBM861
+    | "CSIBM861" -> CSIBM861
+
+    | "863" -> I_863
+    | "CP863" -> CP863
+    | "IBM863" -> IBM863
+    | "CSIBM863" -> CSIBM863
+
+    | "CP864" -> CP864
+    | "IBM864" -> IBM864
+    | "CSIBM864" -> CSIBM864
+
+    | "865" -> I_865
+    | "CP865" -> CP865
+    | "IBM865" -> IBM865
+    | "CSIBM865" -> CSIBM865
+
+    | "869" -> I_869
+    | "CP-GR" -> CP_GR
+    | "CP869" -> CP869
+    | "IBM869" -> IBM869
+    | "CSIBM869" -> CSIBM869
+
+    | "CP1125" -> CP1125
+
+    | _ -> ASCII
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          variables                                             *)
+(*                                                                                *)
+(**********************************************************************************)
+
+(*
+let charset_aliases =
+[
+ [ANSI_X3_4_1968; ANSI_X3_4_1986; ASCII; CP367; IBM367; ISO_IR_6; ISO646_US; ISO_646_IRV_1991; US; US_ASCII; CSASCII];
+ [UTF_8];
+ [ISO_10646_UCS_2; UCS_2; CSUNICODE];
+ [UCS_2BE; UNICODE_1_1; UNICODEBIG; CSUNICODE11];
+ [UCS_2LE; UNICODELITTLE];
+ [ISO_10646_UCS_4; UCS_4; CSUCS4];
+ [UCS_4BE];
+ [UCS_4LE];
+ [UTF_16];
+ [UTF_16BE];
+ [UTF_16LE];
+ [UTF_32];
+ [UTF_32BE];
+ [UTF_32LE];
+ [UNICODE_1_1_UTF_7; UTF_7; CSUNICODE11UTF7];
+ [UCS_2_INTERNAL];
+ [UCS_2_SWAPPED];
+ [UCS_4_INTERNAL];
+ [UCS_4_SWAPPED];
+ [C99];
+ [JAVA];
+ [CP819; IBM819; ISO_8859_1; ISO_IR_100; ISO8859_1; ISO_8859_1_1987; L1; LATIN1; CSISOLATIN1];
+ [ISO_8859_2; ISO_IR_101; ISO8859_2; ISO_8859_2_1987; L2; LATIN2; CSISOLATIN2];
+ [ISO_8859_3; ISO_IR_109; ISO8859_3; ISO_8859_3_1988; L3; LATIN3; CSISOLATIN3];
+ [ISO_8859_4; ISO_IR_110; ISO8859_4; ISO_8859_4_1988; L4; LATIN4; CSISOLATIN4];
+ [CYRILLIC; ISO_8859_5; ISO_IR_144; ISO8859_5; ISO_8859_5_1988; CSISOLATINCYRILLIC];
+ [ARABIC; ASMO_708; ECMA_114; ISO_8859_6; ISO_IR_127; ISO8859_6; ISO_8859_6_1987; CSISOLATINARABIC];
+ [ECMA_118; ELOT_928; GREEK; GREEK8; ISO_8859_7; ISO_IR_126; ISO8859_7; ISO_8859_7_1987; CSISOLATINGREEK];
+ [HEBREW; ISO_8859_8; ISO_IR_138; ISO8859_8; ISO_8859_8_1988; CSISOLATINHEBREW];
+ [ISO_8859_9; ISO_IR_148; ISO8859_9; ISO_8859_9_1989; L5; LATIN5; CSISOLATIN5];
+ [ISO_8859_10; ISO_IR_157; ISO8859_10; ISO_8859_10_1992; L6; LATIN6; CSISOLATIN6];
+ [ISO_8859_13; ISO_IR_179; ISO8859_13; L7; LATIN7];
+ [ISO_8859_14; ISO_CELTIC; ISO_IR_199; ISO_8859_14; ISO_8859_14_1998; L8; LATIN8];
+ [ISO_8859_15; ISO_IR_203; ISO8859_15; ISO_8859_15_1998];
+ [ISO_8859_16; ISO_IR_226; ISO8859_16; ISO_8859_16_2000];
+ [KOI8_R; CSKOI8R];
+ [KOI8_U];
+ [KOI8_RU];
+ [CP1250; MS_EE; WINDOWS_1250];
+ [CP1251; MS_CYRL; WINDOWS_1251];
+ [CP1252; MS_ANSI; WINDOWS_1252];
+ [CP1253; MS_GREEK; WINDOWS_1253];
+ [CP1254; MS_TURK; WINDOWS_1254];
+ [CP1255; MS_HEBR; WINDOWS_1255];
+ [CP1256; MS_ARAB; WINDOWS_1256];
+ [CP1257; WINBALTRIM; WINDOWS_1257];
+ [CP1258; WINDOWS_1258];
+ [I_850; CP850; IBM850; CSPC850MULTILINGUAL];
+ [I_862; CP862; IBM862; CSPC862LATINHEBREW];
+ [I_866; CP866; IBM866; CSIBM866];
+ [MAC; MACINTOSH; MACROMAN; CSMACINTOSH];
+ [MACCENTRALEUROPE];
+ [MACICELAND];
+ [MACCROATIAN];
+ [MACROMANIA];
+ [MACCYRILLIC];
+ [MACUKRAINE];
+ [MACGREEK];
+ [MACTURKISH];
+ [MACHEBREW];
+ [MACARABIC];
+ [MACTHAI];
+ [HP_ROMAN8; R8; ROMAN8; CSHPROMAN8];   (* no region *)
+ [NEXTSTEP];                            (* no region *)
+ [ARMSCII_8];
+ [GEORGIAN_ACADEMY];
+ [GEORGIAN_PS];
+ [KOI8_T];
+ [MULELAO_1];
+ [CP1133; IBM_CP1133];
+ [ISO_IR_166; TIS_620; TIS620; TIS620_0; TIS620_2529_1; TIS620_2533_0; TIS620_2533_1];
+ [CP874; WINDOWS_874];
+ [VISCII; VISCII1_1_1; CSVISCII];
+ [TCVN; TCVN_5712; TCVN5712_1; TCVN5712_1_1993];
+ [ISO_IR_14; ISO646_JP; JIS_C6220_1969_RO; JP; CSISO14JISC6220RO];
+ [JISX0201_1976; JIS_X0201; X0201; CSHALFWIDTHKATAKANA];
+ [ISO_IR_87; JIS0208; JIS_C6226_1983; JIS_X0208; JIS_X0208_1983; JIS_X0208_1990; X0208; CSISO87JISX0208];
+ [ISO_IR_159; JIS_X0212; JIS_X0212_1990; JIS_X0212_1990_0; X0212; CSISO159JISX02121990];
+ [CN; GB_1988_80; ISO_IR_57; ISO646_CN; CSISO57GB1988];
+ [CHINESE; GB_2312_80; ISO_IR_58; CSISO58GB231280];
+ [CN_GB_ISOIR165; ISO_IR_165];
+ [ISO_IR_149; KOREAN; KSC_5601; KS_C_5601_1987; KS_C_5601_1989; CSKSC56011987];
+ [EUC_JP; EUCJP; EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE; CSEUCPKDFMTJAPANESE];
+ [MS_KANJI; SHIFT_JIS; SJIS; CSSHIFTJIS];
+ [CP932];
+ [ISO_2022_JP; CSISO2022JP];
+ [ISO_2022_JP_1];
+ [ISO_2022_JP_2; CSISO2022JP2];
+ [CN_GB; EUC_CN; EUCCN; GB2312; CSGB2312];
+ [CP936; GBK];
+ [GB18030];
+ [ISO_2022_CN; CSISO2022CN];
+ [ISO_2022_CN_EXT];
+ [HZ; HZ_GB_2312];
+ [EUC_TW; EUCTW; CSEUCTW];
+ [BIG_5; BIG_FIVE; BIG5; BIGFIVE; CN_BIG5; CSBIG5];
+ [CP950];
+ [BIG5_HKSCS; BIG5HKSCS];
+ [EUC_KR; EUCKR; CSEUCKR];
+ [CP949; UHC];
+ [CP1361; JOHAB];
+ [ISO_2022_KR; CSISO2022KR];
+ [I_437; CP437; IBM437; CSPC8CODEPAGE437];
+ [CP737];
+ [CP775; IBM775; CSPC775BALTIC];
+ [I_852; CP852; IBM852; CSPCP852];
+ [CP853];                            (* no region *)
+ [I_855; CP855; IBM855; CSIBM855];
+ [I_857; CP857; IBM857; CSIBM857];
+ [CP858];                            (* no region *)
+ [I_860; CP860; IBM860; CSIBM860];
+ [I_861; CP_IS; CP861; IBM861; CSIBM861];
+ [I_863; CP863; IBM863; CSIBM863];
+ [CP864; IBM864; CSIBM864];
+ [I_865; CP865; IBM865; CSIBM865];
+ [I_869; CP_GR; CP869; IBM869; CSIBM869];
+ [CP1125];
+]
+*)
+
+let ascii =
+  [
+   [ANSI_X3_4_1968; ANSI_X3_4_1986; ASCII; CP367; IBM367; ISO_IR_6; ISO646_US; ISO_646_IRV_1991; US; US_ASCII; CSASCII];
+   [C99];
+  ]
+
+let arabic =
+  [
+   [CP1256; MS_ARAB; WINDOWS_1256];
+   [ARABIC; ASMO_708; ECMA_114; ISO_8859_6; ISO_IR_127; ISO8859_6; ISO_8859_6_1987; CSISOLATINARABIC];
+   [CP864; IBM864; CSIBM864]; [CP864; IBM864; CSIBM864];
+   [MACARABIC];
+  ]
+
+let armenian =
+  [
+   [ARMSCII_8];
+  ]
+
+let baltic =
+  [
+   [CP1257; WINBALTRIM; WINDOWS_1257];
+   [ISO_8859_13; ISO_IR_179; ISO8859_13; L7; LATIN7];
+   [ISO_8859_4; ISO_IR_110; ISO8859_4; ISO_8859_4_1988; L4; LATIN4; CSISOLATIN4];
+   [CP775; IBM775; CSPC775BALTIC];
+   [MACUKRAINE];
+   [MACCROATIAN];
+  ]
+
+let celtic =
+  [
+   [ISO_8859_14; ISO_CELTIC; ISO_IR_199; ISO8859_14; ISO_8859_14_1998; L8; LATIN8];
+  ]
+
+let central_european =
+  [
+   [CP1250; MS_EE; WINDOWS_1250];
+   [ISO_8859_2; ISO_IR_101; ISO8859_2; ISO_8859_2_1987; L2; LATIN2; CSISOLATIN2];
+   [I_852; CP852; IBM852; CSPCP852];
+   [MACCENTRALEUROPE];
+  ]
+
+let chinese_simplified =
+  [
+   [GB18030];
+   [CP936; GBK];
+   [CN_GB; EUC_CN; EUCCN; GB2312; CSGB2312];
+   [CHINESE; GB_2312_80; ISO_IR_58; CSISO58GB231280];
+   [CN; GB_1988_80; ISO_IR_57; ISO646_CN; CSISO57GB1988];
+   [CN_GB_ISOIR165; ISO_IR_165];
+   [ISO_2022_CN; CSISO2022CN];
+   [ISO_2022_CN_EXT];
+   [HZ; HZ_GB_2312];
+  ]
+
+let chinese_traditional =
+  [
+   [BIG_5; BIG_FIVE; BIG5; BIGFIVE; CN_BIG5; CSBIG5];
+   [BIG5_HKSCS; BIG5HKSCS];
+   [EUC_TW; EUCTW; CSEUCTW];
+   [CP950];
+  ]
+
+let cyrillic =
+  [
+   [CP1251; MS_CYRL; WINDOWS_1251];
+   [I_866; CP866; IBM866; CSIBM866];
+   [KOI8_R; CSKOI8R];
+   [CYRILLIC; ISO_8859_5; ISO_IR_144; ISO8859_5; ISO_8859_5_1988; CSISOLATINCYRILLIC];
+   [I_855; CP855; IBM855; CSIBM855];
+   [KOI8_U];
+   [KOI8_RU];
+   [MACCYRILLIC];
+   [CP1125];
+  ]
+
+let georgian =
+  [
+   [GEORGIAN_ACADEMY];
+   [GEORGIAN_PS];
+  ]
+
+let greek =
+  [
+   [CP1253; MS_GREEK; WINDOWS_1253];
+   [ECMA_118; ELOT_928; GREEK; GREEK8; ISO_8859_7; ISO_IR_126; ISO8859_7; ISO_8859_7_1987; CSISOLATINGREEK];
+   [MACGREEK];
+   [CP737];
+   [I_869; CP_GR; CP869; IBM869; CSIBM869];
+  ]
+
+let hebrew =
+  [
+   [CP1255; MS_HEBR; WINDOWS_1255];
+   [HEBREW; ISO_8859_8; ISO_IR_138; ISO8859_8; ISO_8859_8_1988; CSISOLATINHEBREW];
+   [I_862; CP862; IBM862; CSPC862LATINHEBREW];
+   [MACHEBREW];
+  ]
+
+let japanese =
+  [
+   [EUC_JP; EUCJP; EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE; CSEUCPKDFMTJAPANESE];
+   [ISO_2022_JP; CSISO2022JP];
+   [ISO_2022_JP_1];
+   [ISO_2022_JP_2; CSISO2022JP2];
+   [MS_KANJI; SHIFT_JIS; SJIS; CSSHIFTJIS];
+   [ISO_IR_14; ISO646_JP; JIS_C6220_1969_RO; JP; CSISO14JISC6220RO];
+   [JISX0201_1976; JIS_X0201; X0201; CSHALFWIDTHKATAKANA];
+   [ISO_IR_87; JIS0208; JIS_C6226_1983; JIS_X0208; JIS_X0208_1983; JIS_X0208_1990; X0208; CSISO87JISX0208];
+   [ISO_IR_159; JIS_X0212; JIS_X0212_1990; JIS_X0212_1990_0; X0212; CSISO159JISX02121990];
+   [CP932];
+  ]
+
+let korean =
+  [
+   [CP949; UHC];
+   [CP1361; JOHAB];
+   [EUC_KR; EUCKR; CSEUCKR];
+   [ISO_2022_KR; CSISO2022KR];
+   [ISO_IR_149; KOREAN; KSC_5601; KS_C_5601_1987; KS_C_5601_1989; CSKSC56011987];
+  ]
+
+let nordic =
+  [
+   [ISO_8859_10; ISO_IR_157; ISO8859_10; ISO_8859_10_1992; L6; LATIN6; CSISOLATIN6];
+   [I_861; CP_IS; CP861; IBM861; CSIBM861];
+   [MACICELAND];
+   [I_865; CP865; IBM865; CSIBM865];
+  ]
+
+let romanian =
+  [
+   [ISO_8859_16; ISO_IR_226; ISO8859_16; ISO_8859_16_2000];
+   [MACROMANIA];
+  ]
+
+let south_european =
+  [
+   [ISO_8859_3; ISO_IR_109; ISO8859_3; ISO_8859_3_1988; L3; LATIN3; CSISOLATIN3];
+  ]
+
+let tajik =
+  [
+   [KOI8_T];
+  ]
+
+let thai =
+  [
+   [CP874; WINDOWS_874];
+   [ISO_IR_166; TIS_620; TIS620; TIS620_0; TIS620_2529_1; TIS620_2533_0; TIS620_2533_1];
+   [MULELAO_1];
+   [CP1133; IBM_CP1133];
+   [MACTHAI];
+  ]
+
+let turkish =
+  [
+   [CP1254; MS_TURK; WINDOWS_1254];
+   [ISO_8859_9; ISO_IR_148; ISO8859_9; ISO_8859_9_1989; L5; LATIN5; CSISOLATIN5];
+   [I_857; CP857; IBM857; CSIBM857];
+   [MACTURKISH];
+  ]
+
+let unicode =
+  [
+   [ISO_10646_UCS_2; UCS_2; CSUNICODE];
+   [UCS_2BE; UNICODE_1_1; UNICODEBIG; CSUNICODE11];
+   [UCS_2LE; UNICODELITTLE];
+   [ISO_10646_UCS_4; UCS_4; CSUCS4];
+   [UCS_4BE];
+   [UCS_4LE];
+   [UTF_16];
+   [UTF_16BE];
+   [UTF_16LE];
+   [UTF_32];
+   [UTF_32BE];
+   [UTF_32LE];
+   [UNICODE_1_1_UTF_7; UTF_7; CSUNICODE11UTF7];
+   [UCS_2_INTERNAL];
+   [UCS_2_SWAPPED];
+   [UCS_4_INTERNAL];
+   [UCS_4_SWAPPED];
+  ]
+
+let vietnamese =
+  [
+   [CP1258; WINDOWS_1258];
+   [VISCII; VISCII1_1_1; CSVISCII];
+   [TCVN; TCVN_5712; TCVN5712_1; TCVN5712_1_1993];
+  ]
+
+let western_european =
+  [
+   [CP1252; MS_ANSI; WINDOWS_1252];
+   [ISO_8859_15; ISO_IR_203; ISO8859_15; ISO_8859_15_1998];
+   [I_850; CP850; IBM850; CSPC850MULTILINGUAL];
+   [CP819; IBM819; ISO_8859_1; ISO_IR_100; ISO8859_1; ISO_8859_1; ISO_8859_1_1987; L1; LATIN1; CSISOLATIN1];
+   [MAC; MACINTOSH; MACROMAN; CSMACINTOSH];
+   [I_437; CP437; IBM437; CSPC8CODEPAGE437];
+   [I_860; CP860; IBM860; CSIBM860];
+   [I_863; CP863; IBM863; CSIBM863];
+  ]
+
+let locale =
+  try
+    let cs = get_charset () in
+    charset_from_string cs
+  with _ -> ASCII
+
+let locstr =
+  let s = charset_to_string locale in
+  Printf.printf "locale is %s\n" s;
+  flush stdout;
+  s
+
+let (enc_list : string list ref) = ref []
+let nenc = ref 0
+
+let all_regions =
+  [
+   ascii;
+   arabic;
+   armenian;
+   baltic;
+   celtic;
+   central_european;
+   chinese_simplified;
+   chinese_traditional;
+   cyrillic;
+   georgian;
+   greek;
+   hebrew;
+   japanese;
+   korean;
+   nordic;
+   romanian;
+   south_european;
+   tajik;
+   thai;
+   turkish;
+   vietnamese;
+   western_european;
+  ]
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          charset_list_from_locale                              *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let charset_list_from_locale loc =
+  let li = ref [] in
+  li := unicode :: !li;
+  List.iter (fun e_list ->
+    List.iter (fun l_list ->
+      if (List.exists (fun c -> c = loc) l_list)
+        then li := e_list :: !li
+    ) e_list
+  ) all_regions;
+  List.flatten !li
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          set_default_charset_list                              *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let set_default_charset_list (loc : charset) =
+  (* Let's get rid of charset aliases *)
+  let l = List.map (fun li -> List.hd li) (charset_list_from_locale loc) in
+  enc_list := List.map (fun c -> charset_to_string c ) l;
+  List.iter (fun enc ->
+    Printf.printf "Use encoding %s\n" enc; 
+    flush stdout
+  ) !enc_list;
+  nenc := List.length !enc_list
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          convert                                               *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let convert ~from_charset ~to_charset s =
+  if s <> "" then begin
+    let t = charset_to_string to_charset in
+    let f = charset_to_string from_charset in
+    convert_string s t f
+  end else s
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          slow_encode                                           *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let slow_encode s to_codeset =
+  let us = ref "" in
+  let slen = String.length s in
+  let char_const = convert_string "_" to_codeset "ASCII" in
+  for i = 0 to (slen - 1) do
+    try
+      us := !us ^ (convert_string (String.sub s i 1) to_codeset locstr)
+    with _ ->
+      us := !us ^ char_const
+  done;
+  !us
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          fast_encode                                           *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let fast_encode s to_codeset =
+  let rec iter i n =
+     if i = n 
+       then slow_encode s to_codeset
+       else
+         try
+           let from_codeset = List.nth !enc_list i in
+           convert_string s to_codeset from_codeset
+         with _ -> iter (i + 1) !nenc
+  in iter 0 !nenc
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          to_utf8                                               *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let to_utf8 s =
+  if is_utf8 s
+    then s
+    else fast_encode s "UTF-8"
+
+(**********************************************************************************)
+(*                                                                                *)
+(*                          to_locale                                             *)
+(*                                                                                *)
+(**********************************************************************************)
+
+let to_locale s =
+  let s = to_utf8 s in
+  match locale with
+      UTF_8 -> s
+    | _ ->
+	begin
+          try
+            convert_string s locstr "UTF-8"
+          with _ ->
+            begin
+              let us = ref "" in
+              let slen = String.length s in
+              let char_const = convert_string "_" locstr "ASCII" in
+              for i = 0 to (slen - 1) do
+                try
+                  us := !us ^ (convert_string (String.sub s i 1) locstr "UTF-8")
+                with _ ->
+                  us := !us ^ char_const
+              done;
+              !us
+            end
+        end
+
+
+let _ =
+  set_default_charset_list locale
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/utils/lib/charset.mli ./src/utils/lib/charset.mli
--- ./src/utils/lib/charset.mli	1970-01-01 01:00:00.000000000 +0100
+++ ./src/utils/lib/charset.mli	2005-04-04 22:34:51.000000000 +0200
@@ -0,0 +1,147 @@
+(* Copyright 2005 b8_bavard, INRIA *)
+(*
+    This file is part of mldonkey.
+
+    mldonkey is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    mldonkey is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mldonkey; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*)
+
+type charset =
+| ANSI_X3_4_1968 | ANSI_X3_4_1986 | ASCII | CP367 | IBM367 | ISO_IR_6 | ISO646_US | ISO_646_IRV_1991 | US | US_ASCII | CSASCII
+| UTF_8
+| ISO_10646_UCS_2 | UCS_2 | CSUNICODE
+| UCS_2BE | UNICODE_1_1 | UNICODEBIG | CSUNICODE11
+| UCS_2LE | UNICODELITTLE
+| ISO_10646_UCS_4 | UCS_4 | CSUCS4
+| UCS_4BE
+| UCS_4LE
+| UTF_16
+| UTF_16BE
+| UTF_16LE
+| UTF_32
+| UTF_32BE
+| UTF_32LE
+| UNICODE_1_1_UTF_7 | UTF_7 | CSUNICODE11UTF7
+| UCS_2_INTERNAL
+| UCS_2_SWAPPED
+| UCS_4_INTERNAL
+| UCS_4_SWAPPED
+| C99
+| JAVA
+| CP819 | IBM819 | ISO_8859_1 | ISO_IR_100 | ISO8859_1 | ISO_8859_1_1987 | L1 | LATIN1 | CSISOLATIN1
+| ISO_8859_2 | ISO_IR_101 | ISO8859_2 | ISO_8859_2_1987 | L2 | LATIN2 | CSISOLATIN2
+| ISO_8859_3 | ISO_IR_109 | ISO8859_3 | ISO_8859_3_1988 | L3 | LATIN3 | CSISOLATIN3
+| ISO_8859_4 | ISO_IR_110 | ISO8859_4 | ISO_8859_4_1988 | L4 | LATIN4 | CSISOLATIN4
+| CYRILLIC | ISO_8859_5 | ISO_IR_144  | ISO8859_5 | ISO_8859_5_1988 | CSISOLATINCYRILLIC
+| ARABIC | ASMO_708 | ECMA_114 | ISO_8859_6 | ISO_IR_127 | ISO8859_6 | ISO_8859_6_1987 | CSISOLATINARABIC
+| ECMA_118 | ELOT_928 | GREEK | GREEK8 | ISO_8859_7 | ISO_IR_126 | ISO8859_7 | ISO_8859_7_1987 | CSISOLATINGREEK
+| HEBREW | ISO_8859_8 | ISO_IR_138 | ISO8859_8 | ISO_8859_8_1988 | CSISOLATINHEBREW
+| ISO_8859_9 | ISO_IR_148 | ISO8859_9 | ISO_8859_9_1989 | L5 | LATIN5 | CSISOLATIN5
+| ISO_8859_10 | ISO_IR_157 | ISO8859_10 | ISO_8859_10_1992 | L6 | LATIN6 | CSISOLATIN6
+| ISO_8859_13 | ISO_IR_179 | ISO8859_13 | L7 | LATIN7
+| ISO_8859_14 | ISO_CELTIC | ISO8859_14 | ISO_IR_199 | ISO_8859_14_1998 | L8 | LATIN8
+| ISO_8859_15 | ISO_IR_203 | ISO8859_15 | ISO_8859_15_1998
+| ISO_8859_16 | ISO_IR_226 | ISO8859_16 | ISO_8859_16_2000
+| KOI8_R | CSKOI8R
+| KOI8_U
+| KOI8_RU
+| CP1250 | MS_EE | WINDOWS_1250
+| CP1251 | MS_CYRL | WINDOWS_1251
+| CP1252 | MS_ANSI | WINDOWS_1252
+| CP1253 | MS_GREEK | WINDOWS_1253
+| CP1254 | MS_TURK | WINDOWS_1254
+| CP1255 | MS_HEBR | WINDOWS_1255
+| CP1256 | MS_ARAB | WINDOWS_1256
+| CP1257 | WINBALTRIM | WINDOWS_1257
+| CP1258 | WINDOWS_1258
+| I_850 | CP850 | IBM850 | CSPC850MULTILINGUAL
+| I_862 | CP862 | IBM862 | CSPC862LATINHEBREW
+| I_866 | CP866 | IBM866 | CSIBM866
+| MAC | MACINTOSH | MACROMAN | CSMACINTOSH
+| MACCENTRALEUROPE
+| MACICELAND
+| MACCROATIAN
+| MACROMANIA
+| MACCYRILLIC
+| MACUKRAINE
+| MACGREEK
+| MACTURKISH
+| MACHEBREW
+| MACARABIC
+| MACTHAI
+| HP_ROMAN8 | R8 | ROMAN8 | CSHPROMAN8
+| NEXTSTEP
+| ARMSCII_8
+| GEORGIAN_ACADEMY
+| GEORGIAN_PS
+| KOI8_T
+| MULELAO_1
+| CP1133 | IBM_CP1133
+| ISO_IR_166 | TIS_620 | TIS620 | TIS620_0 | TIS620_2529_1 | TIS620_2533_0 | TIS620_2533_1
+| CP874 | WINDOWS_874
+| VISCII | VISCII1_1_1 | CSVISCII
+| TCVN | TCVN_5712 | TCVN5712_1 | TCVN5712_1_1993
+| ISO_IR_14 | ISO646_JP | JIS_C6220_1969_RO | JP | CSISO14JISC6220RO
+| JISX0201_1976 | JIS_X0201 | X0201 | CSHALFWIDTHKATAKANA
+| ISO_IR_87 | JIS0208 | JIS_C6226_1983 | JIS_X0208 | JIS_X0208_1983 | JIS_X0208_1990 | X0208 | CSISO87JISX0208
+| ISO_IR_159 | JIS_X0212 | JIS_X0212_1990 | JIS_X0212_1990_0 | X0212 | CSISO159JISX02121990
+| CN | GB_1988_80 | ISO_IR_57 | ISO646_CN | CSISO57GB1988
+| CHINESE | GB_2312_80 | ISO_IR_58 | CSISO58GB231280
+| CN_GB_ISOIR165 | ISO_IR_165
+| ISO_IR_149 | KOREAN | KSC_5601 | KS_C_5601_1987 | KS_C_5601_1989 | CSKSC56011987
+| EUC_JP | EUCJP | EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE | CSEUCPKDFMTJAPANESE
+| MS_KANJI | SHIFT_JIS | SJIS | CSSHIFTJIS
+| CP932
+| ISO_2022_JP | CSISO2022JP
+| ISO_2022_JP_1
+| ISO_2022_JP_2 | CSISO2022JP2
+| CN_GB | EUC_CN | EUCCN | GB2312 | CSGB2312
+| CP936 | GBK
+| GB18030
+| ISO_2022_CN | CSISO2022CN
+| ISO_2022_CN_EXT
+| HZ | HZ_GB_2312
+| EUC_TW | EUCTW | CSEUCTW
+| BIG_5 | BIG_FIVE | BIG5 | BIGFIVE | CN_BIG5 | CSBIG5
+| CP950
+| BIG5_HKSCS | BIG5HKSCS
+| EUC_KR | EUCKR | CSEUCKR
+| CP949 | UHC
+| CP1361 | JOHAB
+| ISO_2022_KR | CSISO2022KR
+| I_437 | CP437 | IBM437 | CSPC8CODEPAGE437
+| CP737
+| CP775 | IBM775 | CSPC775BALTIC
+| I_852 | CP852 | IBM852 | CSPCP852
+| CP853
+| I_855 | CP855 | IBM855 | CSIBM855
+| I_857 | CP857 | IBM857 | CSIBM857
+| CP858
+| I_860 | CP860 | IBM860 | CSIBM860
+| I_861 | CP_IS | CP861 | IBM861 | CSIBM861
+| I_863 | CP863 | IBM863 | CSIBM863
+| CP864 | IBM864 | CSIBM864
+| I_865 | CP865 | IBM865 | CSIBM865
+| I_869 | CP_GR | CP869 | IBM869 | CSIBM869
+| CP1125
+
+(* convert ~from_charset ~to_charset s :
+ * raise CharsetError if the string [s] is not entirely convertible.
+ *)
+
+val convert : from_charset : charset -> to_charset : charset -> string -> string
+
+val is_utf8 : string -> bool
+val to_utf8 : string -> string
+val to_locale : string -> string
diff -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -u -N -r -E -B ./src/utils/lib/charsetstubs.c ./src/utils/lib/charsetstubs.c
--- ./src/utils/lib/charsetstubs.c	1970-01-01 01:00:00.000000000 +0100
+++ ./src/utils/lib/charsetstubs.c	2005-04-04 22:34:51.000000000 +0200
@@ -0,0 +1,349 @@
+/* Copyright 2005 b8_bavard, INRIA */
+/*
+    This file is part of mldonkey.
+
+    mldonkey is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    mldonkey is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mldonkey; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+/* Stub code to interface with libiconv
+ *
+ * taken and modified from
+ *   glib-2.4.7/glib/gconvert.c
+ *   glib-2.4.7/glib/gutf8.c
+ *   lablgtk-2.4.0/src/ml_glib.c
+ *   libiconv-1.9.1/src/iconv.c
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <localcharset.h>
+#include <iconv.h>
+
+#include <caml/mlvalues.h>
+#include <caml/alloc.h>
+#include <caml/callback.h>
+#include <caml/fail.h>
+#include <caml/memory.h>
+
+#define FALSE 0
+#define TRUE  1
+
+#define SizedString_val(x) String_val(x), string_length(x)
+
+#define UTF8_COMPUTE(Char, Mask, Len)					      \
+  if (Char < 128)							      \
+    {									      \
+      Len = 1;								      \
+      Mask = 0x7f;							      \
+    }									      \
+  else if ((Char & 0xe0) == 0xc0)					      \
+    {									      \
+      Len = 2;								      \
+      Mask = 0x1f;							      \
+    }									      \
+  else if ((Char & 0xf0) == 0xe0)					      \
+    {									      \
+      Len = 3;								      \
+      Mask = 0x0f;							      \
+    }									      \
+  else if ((Char & 0xf8) == 0xf0)					      \
+    {									      \
+      Len = 4;								      \
+      Mask = 0x07;							      \
+    }									      \
+  else if ((Char & 0xfc) == 0xf8)					      \
+    {									      \
+      Len = 5;								      \
+      Mask = 0x03;							      \
+    }									      \
+  else if ((Char & 0xfe) == 0xfc)					      \
+    {									      \
+      Len = 6;								      \
+      Mask = 0x01;							      \
+    }									      \
+  else									      \
+    Len = -1;
+
+#define UTF8_LENGTH(Char)              \
+  ((Char) < 0x80 ? 1 :                 \
+   ((Char) < 0x800 ? 2 :               \
+    ((Char) < 0x10000 ? 3 :            \
+     ((Char) < 0x200000 ? 4 :          \
+      ((Char) < 0x4000000 ? 5 : 6)))))
+   
+
+#define UTF8_GET(Result, Chars, Count, Mask, Len)			      \
+  (Result) = (Chars)[0] & (Mask);					      \
+  for ((Count) = 1; (Count) < (Len); ++(Count))				      \
+    {									      \
+      if (((Chars)[(Count)] & 0xc0) != 0x80)				      \
+	{								      \
+	  (Result) = -1;						      \
+	  break;							      \
+	}								      \
+      (Result) <<= 6;							      \
+      (Result) |= ((Chars)[(Count)] & 0x3f);				      \
+    }
+
+#define UNICODE_VALID(Char)                   \
+    ((Char) < 0x110000 &&                     \
+     (((Char) & 0xFFFFF800) != 0xD800) &&     \
+     ((Char) < 0xFDD0 || (Char) > 0xFDEF) &&  \
+     ((Char) & 0xFFFE) != 0xFFFE)
+
+void
+raise_error(void)
+{
+  static value * closure_f = NULL;
+  if (closure_f == NULL) {
+    /* First time around, look up by name */
+    closure_f = caml_named_value("charset_error");
+  }
+  raise_constant(*closure_f);
+}
+
+int
+utf8_validate (const char  *str,
+               size_t      max_len,    
+               const char  **end)
+{
+
+  const char *p;
+
+  if (str == NULL)
+    return FALSE;
+
+  if (end)
+    *end = str;
+  
+  p = str;
+  
+  while ((max_len < 0 || (p - str) < max_len) && *p)
+    {
+      int i, mask = 0, len;
+      unsigned int result;
+      unsigned char c = (unsigned char) *p;
+      
+      UTF8_COMPUTE (c, mask, len);
+
+      if (len == -1)
+        break;
+
+      /* check that the expected number of bytes exists in str */
+      if (max_len >= 0 &&
+          ((max_len - (p - str)) < len))
+        break;
+        
+      UTF8_GET (result, p, i, mask, len);
+
+      if (UTF8_LENGTH (result) != len) /* Check for overlong UTF-8 */
+	break;
+
+      if (result == (unsigned int)-1)
+        break;
+
+      if (!UNICODE_VALID (result))
+	break;
+      
+      p += len;
+    }
+
+  if (end)
+    *end = p;
+
+  /* See that we covered the entire length if a length was
+   * passed in, or that we ended on a nul if not
+   */
+  if (max_len >= 0 &&
+      p != (str + max_len))
+    return FALSE;
+  else if (max_len < 0 &&
+           *p != '\0')
+    return FALSE;
+  else
+    return TRUE;
+}
+
+size_t 
+ml_iconv (iconv_t cd,
+          char    **inbuf,
+          size_t  *inbytes_left,
+          char    **outbuf,
+          size_t  *outbytes_left)
+{
+  return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
+}
+
+char*
+ml_convert_with_iconv (const char *str,
+                       size_t     len,
+                       iconv_t    cd,
+                       size_t     *bytes_read, 
+                       size_t     *bytes_written)
+{
+  char *dest;
+  char *outp;
+  const char *p;
+  size_t inbytes_remaining;
+  size_t outbytes_remaining;
+  size_t outbuf_size;
+  size_t err;
+  int have_error = FALSE;
+
+  if (len < 0)
+    len = strlen (str);
+
+  p = str;
+  inbytes_remaining = len;
+  outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
+  
+  outbytes_remaining = outbuf_size - 1; /* -1 for nul */
+  outp = dest = malloc (outbuf_size);
+
+ again:
+  
+  err = ml_iconv (cd, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining);
+
+  if (err == (size_t) -1)
+    {
+      switch (errno)
+	{
+	case EINVAL:
+	  /* Incomplete text, do not report an error */
+	  break;
+	case E2BIG:
+	  {
+	    size_t used = outp - dest;
+
+	    outbuf_size *= 2;
+	    dest = realloc (dest, outbuf_size);
+		
+	    outp = dest + used;
+	    outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
+
+	    goto again;
+	  }
+	case EILSEQ:
+	  have_error = TRUE;
+	  break;
+	default:
+	  have_error = TRUE;
+	  break;
+	}
+    }
+
+  *outp = '\0';
+  
+  if (bytes_read)
+    *bytes_read = p - str;
+  else
+    {
+      if ((p - str) != len) 
+	{
+          if (!have_error)
+            {
+              have_error = TRUE;
+            }
+	}
+    }
+
+  if (bytes_written)
+    *bytes_written = outp - dest;	/* Doesn't include '\0' */
+
+  if (have_error)
+    {
+      free (dest);
+      return NULL;
+    }
+  else
+    return dest;
+}
+
+char*
+ml_convert (const char *str,
+            size_t     len,  
+            const char *to_codeset,
+            const char *from_codeset,
+            size_t     *bytes_read, 
+	    size_t     *bytes_written)
+{
+  char *res;
+  iconv_t cd;
+
+  cd = iconv_open (to_codeset, from_codeset);
+
+  if (cd == (iconv_t) -1)
+    {
+      if (bytes_read)
+        *bytes_read = 0;
+      
+      if (bytes_written)
+        *bytes_written = 0;
+      
+      return NULL;
+    }
+
+  res = ml_convert_with_iconv (str, len, cd,
+			      bytes_read, bytes_written);
+  
+  iconv_close (cd);
+
+  return res;
+}
+
+static value
+ml_copy_string_len_and_free (char *str, size_t len)
+{
+  value v;
+
+  if (!str)
+    raise_error ();
+
+  v = alloc_string (len);
+  memcpy (String_val(v), str, len);
+  free (str);
+  return v;
+}
+
+value ml_convert_string(value str, value to, value from)
+{
+  size_t bw = 0;
+  char* c_res;
+
+  c_res = ml_convert(String_val(str),string_length(str),
+                    String_val(to),String_val(from),
+                    NULL,&bw);
+
+  return ml_copy_string_len_and_free (c_res, bw);
+}
+
+value ml_utf8_validate(value s)
+{
+  return Val_bool(utf8_validate(SizedString_val(s),NULL));
+}
+
+value ml_locale_charset(void)
+{
+
+  const char *str;
+
+  str = locale_charset ();
+
+  if (!str)
+    raise_error ();
+
+  return (copy_string ((char*) str));
+}
