Index: ./configure.in
===================================================================
--- ./configure.in
+++ ./configure.in	Fri May 17 17:19:18 2002
@@ -360,6 +360,16 @@
 AC_SUBST(SVN_RA_LIB_LINK)
 
 
+dnl descide whether we want to activate real UTF-8 translations
+AC_ARG_ENABLE(utf8,
+[  --enable-utf8             Turn on real UTF-8 strings],
+[
+    if test "$enableval" = "yes"; then
+      enable_utf8=yes
+      CFLAGS="$CFLAGS -DSVN_UTF8";
+    fi
+])
+
 dnl Pass some config data ----------------------------
 
 AC_SUBST(abs_builddir)
Index: ./subversion/libsvn_wc/props.c
===================================================================
--- ./subversion/libsvn_wc/props.c
+++ ./subversion/libsvn_wc/props.c	Wed May 22 15:27:55 2002
@@ -40,6 +40,7 @@
 #include "svn_hash.h"
 #include "svn_wc.h"
 #include "svn_time.h"
+#include "svn_utf.h"
 
 #include "wc.h"
 #include "log.h"
@@ -230,6 +231,7 @@
                         apr_pool_t *pool)
 {
   enum svn_node_kind kind;
+  svn_stringbuf_t *propfile_path_native;
 
   SVN_ERR (svn_io_check_path (propfile_path, &kind, pool));
 
@@ -239,7 +241,10 @@
       apr_status_t status;
       apr_file_t *propfile = NULL;
 
-      status = apr_file_open (&propfile, propfile_path,
+      SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (propfile_path,
+                                                    &propfile_path_native,
+                                                    pool));
+      status = apr_file_open (&propfile, propfile_path_native->data,
                          APR_READ, APR_OS_DEFAULT, pool);
       if (status)
         return svn_error_createf (status, 0, NULL, pool,
@@ -274,8 +279,12 @@
 {
   apr_status_t apr_err;
   apr_file_t *prop_tmp;
+  svn_stringbuf_t *propfile_path_native;
 
-  apr_err = apr_file_open (&prop_tmp, propfile_path,
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (propfile_path,
+                                                &propfile_path_native,
+                                                pool));
+  apr_err = apr_file_open (&prop_tmp, propfile_path_native->data,
                       (APR_WRITE | APR_CREATE | APR_TRUNCATE),
                       APR_OS_DEFAULT, pool);
   if (apr_err)
@@ -1175,8 +1184,12 @@
     {
       apr_finfo_t finfo;
       apr_status_t status;
+      svn_stringbuf_t *path_to_prop_file_native;
 
-      status = apr_stat (&finfo, path_to_prop_file->data, APR_FINFO_MIN, pool);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (path_to_prop_file,
+                                            &path_to_prop_file_native, pool));
+      status = apr_stat (&finfo, path_to_prop_file_native->data,
+                         APR_FINFO_MIN, pool);
       if (status)
         return svn_error_createf (status, 0, NULL, pool,
                                   "couldn't stat '%s'...",
Index: ./subversion/libsvn_wc/adm_crawler.c
===================================================================
--- ./subversion/libsvn_wc/adm_crawler.c
+++ ./subversion/libsvn_wc/adm_crawler.c	Sun May 19 01:06:22 2002
@@ -33,6 +33,7 @@
 #include "svn_io.h"
 #include "svn_sorts.h"
 #include "svn_delta.h"
+#include "svn_utf.h"
 
 #include "wc.h"
 #include "adm_files.h"
@@ -437,7 +438,7 @@
                              svn_stringbuf_t **tempfile,
                              apr_pool_t *pool)
 {
-  svn_stringbuf_t *tmpf, *tmp_base;
+  svn_stringbuf_t *tmpf, *tmp_base, *tmp_base_native;
   apr_status_t status;
   svn_txdelta_window_handler_t handler;
   void *wh_baton;
@@ -524,8 +525,10 @@
         SVN_ERR (svn_wc__open_text_base (&basefile, path, APR_READ, pool));
     }
 
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (tmp_base, &tmp_base_native, pool));
+
   /* Open a filehandle for tmp text-base. */
-  if ((status = apr_file_open (&localfile, tmp_base->data, 
+  if ((status = apr_file_open (&localfile, tmp_base_native->data, 
                                APR_READ, APR_OS_DEFAULT, pool)))
     {
       return svn_error_createf (status, 0, NULL, pool,
Index: ./subversion/libsvn_wc/log.c
===================================================================
--- ./subversion/libsvn_wc/log.c
+++ ./subversion/libsvn_wc/log.c	Wed May 22 15:27:57 2002
@@ -29,6 +29,7 @@
 #include "svn_string.h"
 #include "svn_xml.h"
 #include "svn_pools.h"
+#include "svn_utf.h"
 
 #include "wc.h"
 #include "log.h"
@@ -81,6 +82,7 @@
 {
   apr_status_t status;
   svn_stringbuf_t *full_from_path, *full_dest_path;
+  svn_stringbuf_t *full_from_path_native, *full_dest_path_native;
 
   full_from_path = svn_stringbuf_dup (path, pool);
   full_dest_path = svn_stringbuf_dup (path, pool);
@@ -150,8 +152,12 @@
       /* Remove read-only flag on destination. */
       SVN_ERR (svn_io_set_file_read_write (full_dest_path->data, TRUE, pool));
 
-      status = apr_file_rename (full_from_path->data,
-                              full_dest_path->data, pool);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (full_from_path,
+                                            &full_from_path_native, pool));
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (full_dest_path,
+                                            &full_dest_path_native, pool));
+      status = apr_file_rename (full_from_path_native->data,
+                              full_dest_path_native->data, pool);
 
       /* If we got an ENOENT, that's ok;  the move has probably
          already completed in an earlier run of this log.  */
@@ -349,9 +355,12 @@
     {
       svn_stringbuf_t *infile_path
         = svn_stringbuf_dup (loggy->path, loggy->pool);
+      svn_stringbuf_t *infile_path_native;
       svn_path_add_component_nts (infile_path, infile_name);
       
-      apr_err = apr_file_open (&infile, infile_path->data, APR_READ,
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (infile_path, &infile_path_native,
+                                            loggy->pool));
+      apr_err = apr_file_open (&infile, infile_path_native->data, APR_READ,
                           APR_OS_DEFAULT, loggy->pool);
       if (apr_err)
         return svn_error_createf (apr_err, 0, NULL, loggy->pool,
@@ -362,11 +371,14 @@
     {
       svn_stringbuf_t *outfile_path
         = svn_stringbuf_dup (loggy->path, loggy->pool);
+      svn_stringbuf_t *outfile_path_native;
       svn_path_add_component_nts (outfile_path, outfile_name);
       
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (outfile_path, &outfile_path_native,
+                                            loggy->pool));
       /* kff todo: always creates and overwrites, currently.
          Could append if file exists... ?  Consider. */
-      apr_err = apr_file_open (&outfile, outfile_path->data, 
+      apr_err = apr_file_open (&outfile, outfile_path_native->data, 
                           (APR_WRITE | APR_CREATE),
                           APR_OS_DEFAULT, loggy->pool);
       if (apr_err)
@@ -378,11 +390,14 @@
     {
       svn_stringbuf_t *errfile_path
         = svn_stringbuf_dup (loggy->path, loggy->pool);
+      svn_stringbuf_t *errfile_path_native;
       svn_path_add_component_nts (errfile_path, errfile_name);
       
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (errfile_path, &errfile_path_native,
+                                            loggy->pool));
       /* kff todo: always creates and overwrites, currently.
          Could append if file exists... ?  Consider. */
-      apr_err = apr_file_open (&errfile, errfile_path->data, 
+      apr_err = apr_file_open (&errfile, errfile_path_native->data, 
                           (APR_WRITE | APR_CREATE),
                           APR_OS_DEFAULT, loggy->pool);
       if (apr_err)
@@ -498,12 +513,14 @@
 log_do_rm (struct log_runner *loggy, const char *name)
 {
   apr_status_t apr_err;
-  svn_stringbuf_t *full_path;
+  svn_stringbuf_t *full_path, *full_path_native;
 
   full_path = svn_stringbuf_dup (loggy->path, loggy->pool);
   svn_path_add_component_nts (full_path, name);
 
-  apr_err = apr_file_remove (full_path->data, loggy->pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (full_path, &full_path_native,
+                                        loggy->pool));
+  apr_err = apr_file_remove (full_path_native->data, loggy->pool);
   if (apr_err)
     return svn_error_createf (apr_err, 0, NULL, loggy->pool,
                               "apr_file_remove couldn't remove %s", name);
@@ -868,7 +885,7 @@
      Also, we have to again decide which timestamp to use (see the
      text-time case above).  */
   {
-    svn_stringbuf_t *wf, *tmpf, *basef;
+    svn_stringbuf_t *wf, *tmpf, *basef, *tmpf_native, *basef_native;
 
     SVN_ERR (svn_wc__prop_path (&tmpf, is_this_dir ? loggy->path : full_path,
                                 1, pool));
@@ -934,7 +951,10 @@
         /* Make the tmp prop file the new pristine one.  Note that we
            have to temporarily set the file permissions for writability. */
         SVN_ERR (svn_io_set_file_read_write (basef->data, TRUE, pool));
-        if ((status = apr_file_rename (tmpf->data, basef->data, pool)))
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (tmpf, &tmpf_native, pool));
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (basef, &basef_native, pool));
+        if ((status = apr_file_rename (tmpf_native->data, basef_native->data,
+                                       pool)))
           return svn_error_createf (status, 0, NULL, pool, 
                                     "error renaming `%s' to `%s'",
                                     tmpf->data, basef->data);
Index: ./subversion/libsvn_wc/adm_files.c
===================================================================
--- ./subversion/libsvn_wc/adm_files.c
+++ ./subversion/libsvn_wc/adm_files.c	Wed May 22 15:27:58 2002
@@ -36,6 +36,7 @@
 #include "svn_io.h"
 #include "svn_path.h"
 #include "svn_wc.h"
+#include "svn_utf.h"
 
 #include "wc.h"
 #include "adm_files.h"
@@ -215,12 +216,15 @@
   apr_file_t *f = NULL;
   apr_status_t apr_err = 0;
   int components_added;
+  svn_stringbuf_t *path_native;
 
   components_added = extend_with_adm_name (path, NULL, tmp, pool, thing, NULL);
 
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+
   if (type == svn_node_file)
     {
-      apr_err = apr_file_open (&f, path->data,
+      apr_err = apr_file_open (&f, path_native->data,
                           (APR_WRITE | APR_CREATE | APR_EXCL),
                           perms,
                           pool);
@@ -237,7 +241,7 @@
     }
   else if (type == svn_node_dir)
     {
-      apr_err = apr_dir_make (path->data, perms, pool);
+      apr_err = apr_dir_make (path_native->data, perms, pool);
       if (apr_err)
         err = svn_error_create (apr_err, 0, NULL, pool, path->data);
     }
@@ -272,10 +276,12 @@
     return err;
   else if (kind == svn_node_none)
     {
+      svn_stringbuf_t *dst_native;
       /* SRC doesn't exist, create DST empty. */
       apr_file_t *f = NULL;
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (dst, &dst_native, pool));
       apr_err = apr_file_open (&f,
-                          dst->data,
+                          dst_native->data,
                           (APR_WRITE | APR_CREATE),
                           APR_OS_DEFAULT,
                           pool);
@@ -314,6 +320,7 @@
      given how C va_lists work. */
 
   svn_stringbuf_t *tmp_path = svn_stringbuf_dup (path, pool);
+  svn_stringbuf_t *path_native, *tmp_path_native;
   apr_status_t apr_err;
   int components_added;
   va_list ap;
@@ -332,7 +339,9 @@
   SVN_ERR (svn_io_set_file_read_write (path->data, TRUE, pool));
  
   /* Rename. */
-  apr_err = apr_file_rename (tmp_path->data, path->data, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (tmp_path, &tmp_path_native, pool));
+  apr_err = apr_file_rename (tmp_path_native->data, path_native->data, pool);
   if (! apr_err)
     SVN_ERR (svn_io_set_file_read_only (path->data, FALSE, pool));
 
@@ -567,6 +576,7 @@
   apr_status_t apr_err = 0;
   int components_added;
   va_list ap;
+  svn_stringbuf_t *path_native;
 
   /* If we're writing, always do it to a tmp file. */
   if (flags & APR_WRITE)
@@ -607,7 +617,9 @@
       va_end (ap);
     }
 
-  apr_err = apr_file_open (handle, path->data, flags, APR_OS_DEFAULT, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+  apr_err = apr_file_open (handle, path_native->data, flags,
+                           APR_OS_DEFAULT, pool);
   if (apr_err)
     {
       /* Oddly enough, APR will set *HANDLE even if the open failed.
@@ -663,6 +675,7 @@
          given how C va_lists work. */
 
       svn_stringbuf_t *tmp_path = svn_stringbuf_dup (path, pool);
+      svn_stringbuf_t *path_native, *tmp_path_native;
       
       /* Extend real name. */
       va_start (ap, pool);
@@ -679,7 +692,10 @@
       SVN_ERR (svn_io_set_file_read_write (path->data, TRUE, pool));
       
       /* Rename. */
-      apr_err = apr_file_rename (tmp_path->data, path->data, pool);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (tmp_path, &tmp_path_native, pool));
+      apr_err = apr_file_rename (tmp_path_native->data, path_native->data,
+                                 pool);
       if (! apr_err)
         SVN_ERR (svn_io_set_file_read_only (path->data, FALSE, pool));
       
@@ -738,6 +754,7 @@
   apr_status_t apr_err = 0;
   int components_added;
   va_list ap;
+  svn_stringbuf_t *path_native;
 
   va_start (ap, pool);
   components_added = v_extend_with_adm_name (path, NULL, 0, pool, ap);
@@ -746,6 +763,7 @@
   /* Remove read-only flag on path. */
   SVN_ERR(svn_io_set_file_read_write (path->data, FALSE, pool));
 
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
   apr_err = apr_file_remove (path->data, pool);
   if (apr_err)
     err = svn_error_create (apr_err, 0, NULL, pool, path->data);
Index: ./subversion/libsvn_wc/questions.c
===================================================================
--- ./subversion/libsvn_wc/questions.c
+++ ./subversion/libsvn_wc/questions.c	Sun May 19 01:31:53 2002
@@ -31,6 +31,7 @@
 #include "svn_path.h"
 #include "svn_time.h"
 #include "svn_wc.h"
+#include "svn_utf.h"
 
 #include "wc.h"
 #include "adm_files.h"
@@ -207,15 +208,18 @@
   char buf1[BUFSIZ], buf2[BUFSIZ];
   apr_file_t *file1_h = NULL;
   apr_file_t *file2_h = NULL;
+  svn_stringbuf_t *file1_native, *file2_native;
 
-  status = apr_file_open (&file1_h, file1, 
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (file1, &file1_native, pool));
+  status = apr_file_open (&file1_h, file1_native->data, 
                           APR_READ, APR_OS_DEFAULT, pool);
   if (status)
     return svn_error_createf
       (status, 0, NULL, pool,
        "contents_identical_p: apr_file_open failed on `%s'", file1);
 
-  status = apr_file_open (&file2_h, file2, APR_READ, 
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (file2, &file2_native, pool));
+  status = apr_file_open (&file2_h, file2_native->data, APR_READ, 
                           APR_OS_DEFAULT, pool);
   if (status)
     return svn_error_createf
Index: ./subversion/libsvn_wc/translate.c
===================================================================
--- ./subversion/libsvn_wc/translate.c
+++ ./subversion/libsvn_wc/translate.c	Sun May 19 01:36:55 2002
@@ -38,6 +38,7 @@
 #include "svn_io.h"
 #include "svn_hash.h"
 #include "svn_wc.h"
+#include "svn_utf.h"
 
 #include "wc.h"
 #include "adm_files.h"
@@ -439,19 +440,23 @@
   apr_size_t keyword_off = 0;
   char       src_format[2] = { 0 };
   apr_size_t src_format_len = 0;
+  svn_stringbuf_t *src_native, *dst_native;
 
   if (! (eol_str || keywords))
     return svn_io_copy_file (src, dst, FALSE, pool);
 
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (src, &src_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (dst, &dst_native, pool));
+
   /* Open source file. */
-  apr_err = apr_file_open (&s, src, APR_READ | APR_BUFFERED,
+  apr_err = apr_file_open (&s, src_native->data, APR_READ | APR_BUFFERED,
                            APR_OS_DEFAULT, pool);
   if (apr_err)
     return translate_err (apr_err, "opening", src, pool);
   
   /* Open dest file. */
   apr_err
-    = apr_file_open (&d, dst,
+    = apr_file_open (&d, dst_native->data,
                      APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED,
                      APR_OS_DEFAULT, pool);
   if (apr_err)
@@ -696,7 +701,7 @@
     apr_file_close (s); /* toss error */
   if (d)
     apr_file_close (d); /* toss error */
-  apr_file_remove (dst, pool); /* toss error */
+  apr_file_remove (dst_native->data, pool); /* toss error */
   return err;
 #endif /* ! SVN_TRANSLATE */
 }
Index: ./subversion/libsvn_subr/io.c
===================================================================
--- ./subversion/libsvn_subr/io.c
+++ ./subversion/libsvn_subr/io.c	Wed May 22 22:30:39 2002
@@ -36,6 +36,7 @@
 #include "svn_io.h"
 #include "svn_base64.h"
 #include "svn_pools.h"
+#include "svn_utf.h"
 #include "svn_private_config.h" /* for SVN_CLIENT_DIFF */
 
 
@@ -55,11 +56,14 @@
 {
   apr_finfo_t finfo;
   apr_status_t apr_err;
+  svn_stringbuf_t *path_native;
 
   if (path[0] == '\0')
     path = ".";
 
-  apr_err = apr_stat (&finfo, path, APR_FINFO_MIN, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+
+  apr_err = apr_stat (&finfo, path_native->data, APR_FINFO_MIN, pool);
 
   if (apr_err && !APR_STATUS_IS_ENOENT(apr_err))
     return svn_error_createf
@@ -95,6 +99,7 @@
   char number_buf[6];
   int i;
   apr_size_t iterating_portion_idx;
+  svn_stringbuf_t *unique_name_native;
 
   /* The random portion doesn't have to be very random; it's just to
      avoid a series of collisions where someone has filename NAME and
@@ -145,7 +150,10 @@
       (*unique_name)->data[iterating_portion_idx + 3] = number_buf[3];
       (*unique_name)->data[iterating_portion_idx + 4] = number_buf[4];
 
-      apr_err = apr_file_open (f, (*unique_name)->data, flag,
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (*unique_name, &unique_name_native,
+                                            pool));
+
+      apr_err = apr_file_open (f, unique_name_native->data, flag,
                                APR_OS_DEFAULT, pool);
 
       if (APR_STATUS_IS_EEXIST(apr_err))
@@ -196,7 +204,11 @@
   apr_int32_t options = APR_OS_DEFAULT;
 #endif
 
-  apr_err = apr_file_copy (src, dst, options, pool);
+  svn_stringbuf_t *src_native, *dst_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (src, &src_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (dst, &dst_native, pool));
+
+  apr_err = apr_file_copy (src_native->data, dst_native->data, options, pool);
   if (apr_err)
     return svn_error_createf
       (apr_err, 0, NULL, pool, "svn_io_copy_file: copying %s to %s", src, dst);
@@ -210,7 +222,12 @@
 {
   apr_status_t apr_err;
 
-  apr_err = apr_file_append (src->data, dst->data, APR_OS_DEFAULT, pool);
+  svn_stringbuf_t *src_native, *dst_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (src, &src_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (dst, &dst_native, pool));
+
+  apr_err = apr_file_append (src_native->data, dst_native->data,
+                             APR_OS_DEFAULT, pool);
   if (apr_err)
     {
       const char *msg
@@ -234,6 +251,7 @@
   apr_hash_t *dirents;
   apr_hash_index_t *hi;
   svn_stringbuf_t *dst_path, *src_target, *dst_target;
+  svn_stringbuf_t *dst_path_native;
 
   /* Make a subpool for recursion */
   apr_pool_t *subpool = svn_pool_create (pool);
@@ -260,10 +278,12 @@
   if (kind != svn_node_none)
     return svn_error_createf (SVN_ERR_ENTRY_EXISTS, 0, NULL, subpool,
                               "'%s' already exists.", dst_path->data);
-  
+
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (dst_path, &dst_path_native, pool));
+
   /* Create the new directory. */
   /* ### TODO: copy permissions? */
-  status = apr_dir_make (dst_path->data, APR_OS_DEFAULT, pool);
+  status = apr_dir_make (dst_path_native->data, APR_OS_DEFAULT, pool);
   if (status)
     return svn_error_createf (status, 0, NULL, pool,
                               "Unable to create directory '%s'",
@@ -335,8 +355,11 @@
 {
   apr_finfo_t finfo;
   apr_status_t apr_err;
+  svn_stringbuf_t *path_native;
+
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
 
-  apr_err = apr_stat (&finfo, path->data, APR_FINFO_MIN, pool);
+  apr_err = apr_stat (&finfo, path_native->data, APR_FINFO_MIN, pool);
   if (apr_err)
     return svn_error_createf
       (apr_err, 0, NULL, pool,
@@ -361,8 +384,12 @@
   apr_finfo_t finfo2;
   apr_status_t status;
 
+  svn_stringbuf_t *file1_native, *file2_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (file1, &file1_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (file2, &file2_native, pool));
+
   /* Stat both files */
-  status = apr_stat (&finfo1, file1, APR_FINFO_MIN, pool);
+  status = apr_stat (&finfo1, file1_native->data, APR_FINFO_MIN, pool);
   if (status)
     {
       /* If we got an error stat'ing a file, it could be because the
@@ -373,7 +400,7 @@
       return SVN_NO_ERROR;
     }
 
-  status = apr_stat (&finfo2, file2, APR_FINFO_MIN, pool);
+  status = apr_stat (&finfo2, file2_native->data, APR_FINFO_MIN, pool);
   if (status)
     {
       /* See previous comment. */
@@ -403,6 +430,7 @@
   unsigned char digest[MD5_DIGESTSIZE];
   char buf[BUFSIZ];  /* What's a good size for a read chunk? */
   svn_stringbuf_t *md5str;
+  svn_stringbuf_t *file_native;
 
   /* ### The apr_md5 functions return apr_status_t, but they only
      return success, and really, what could go wrong?  So below, we
@@ -410,7 +438,10 @@
 
   apr_md5_init (&context);
 
-  apr_err = apr_file_open (&f, file, APR_READ, APR_OS_DEFAULT, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (file, &file_native, pool));
+
+  apr_err = apr_file_open (&f, file_native->data, APR_READ, APR_OS_DEFAULT,
+                           pool);
   if (apr_err)
     return svn_error_createf
       (apr_err, 0, NULL, pool,
@@ -459,7 +490,9 @@
                            apr_pool_t *pool)
 {
   apr_status_t status;
-  status = apr_file_attrs_set (path,
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+  status = apr_file_attrs_set (path_native->data,
                                APR_FILE_ATTR_READONLY,
                                APR_FILE_ATTR_READONLY,
                                pool);
@@ -477,7 +510,9 @@
                             apr_pool_t *pool)
 {
   apr_status_t status;
-  status = apr_file_attrs_set (path,
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+  status = apr_file_attrs_set (path_native->data,
                                0,
                                APR_FILE_ATTR_READONLY,
                                pool);
@@ -496,14 +531,16 @@
                             apr_pool_t *pool)
 {
   apr_status_t status;
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
 
   if (executable)
-    status = apr_file_attrs_set (path,
+    status = apr_file_attrs_set (path_native->data,
                                  APR_FILE_ATTR_EXECUTABLE,
                                  APR_FILE_ATTR_EXECUTABLE,
                                  pool);
   else
-    status = apr_file_attrs_set (path,
+    status = apr_file_attrs_set (path_native->data,
                                  0,
                                  APR_FILE_ATTR_EXECUTABLE,
                                  pool);
@@ -800,6 +837,7 @@
 {
   apr_status_t apr_err;
   apr_file_t *f = NULL;
+  svn_stringbuf_t *filename_native;
 
   /* If user passed '-', use stdin. We could use apr_file_open_stdin here, and
    * in fact, it does work. Problem is that if the same command invokes the
@@ -811,7 +849,11 @@
         (SVN_ERR_UNSUPPORTED_FEATURE, 0, NULL, pool,
          "reading from stdin is currently broken, so disabled");
 
-  apr_err = apr_file_open (&f, filename, APR_READ, APR_OS_DEFAULT, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (filename, &filename_native,
+                                                pool));
+
+  apr_err = apr_file_open (&f, filename_native->data, APR_READ,
+                           APR_OS_DEFAULT, pool);
   if (apr_err)
     return svn_error_createf (apr_err, 0, NULL, pool,
                               "read_from_file: failed to open '%s'",
@@ -865,10 +907,15 @@
     }
 
   /* Having read all the data we *expect* EOF */
-  if (!APR_STATUS_IS_EOF(apr_err))
+  if (!APR_STATUS_IS_EOF(apr_err)) {
+    svn_stringbuf_t *fname_utf8;
+
+    SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (fname, &fname_utf8, pool));
+
     return svn_error_createf 
       (apr_err, 0, NULL, pool,
-       "svn_string_from_aprfile: EOF not seen for '%s'", fname);
+       "svn_string_from_aprfile: EOF not seen for '%s'", fname_utf8->data);
+  }
 
   /* Null terminate the stringbuf. */
   res->data[res->len] = 0;
@@ -885,11 +932,13 @@
 svn_io_remove_file (const char *path, apr_pool_t *pool)
 {
   apr_status_t apr_err;
+  svn_stringbuf_t *path_native;
 
   /* Remove read-only flag on terminated file. */
   SVN_ERR (svn_io_set_file_read_write (path, TRUE, pool));
 
-  apr_err = apr_file_remove (path, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+  apr_err = apr_file_remove (path_native->data, pool);
 
   if (apr_err)
     return svn_error_createf
@@ -915,8 +964,10 @@
   apr_finfo_t this_entry;
   apr_pool_t *subpool = svn_pool_create (pool);
   apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME;
+  svn_stringbuf_t *path_native;
 
-  status = apr_dir_open (&this_dir, path, subpool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, subpool));
+  status = apr_dir_open (&this_dir, path_native->data, subpool);
   if (status)
     return svn_error_createf (status, 0, NULL, subpool, err_msg_fmt, path);
 
@@ -924,7 +975,13 @@
        status == APR_SUCCESS;
        status = apr_dir_read (&this_entry, flags, this_dir))
     {
-      char *fullpath = apr_pstrcat (subpool, path, "/", this_entry.name, NULL);
+      svn_stringbuf_t *entry_utf8;
+      char *fullpath;
+
+      SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (this_entry.name,
+                                                  &entry_utf8, subpool));
+
+      fullpath = apr_pstrcat (subpool, path, "/", entry_utf8->data, NULL);
 
       if (this_entry.filetype == APR_DIR)
         {
@@ -954,7 +1011,7 @@
         return svn_error_createf (status, 0, NULL, subpool, err_msg_fmt, path);
     }
 
-  status = apr_dir_remove (path, subpool);
+  status = apr_dir_remove (path_native->data, subpool);
   if (status)
     return svn_error_createf (status, 0, NULL, subpool, err_msg_fmt, path);
 
@@ -974,6 +1031,7 @@
   apr_dir_t *this_dir;
   apr_finfo_t this_entry;
   apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME;
+  svn_stringbuf_t *path_native;
 
   /* These exist so we can use their addresses as hash values! */
   static const enum svn_node_kind static_svn_node_file = svn_node_file;
@@ -982,7 +1040,9 @@
 
   *dirents = apr_hash_make (pool);
   
-  status = apr_dir_open (&this_dir, path->data, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+
+  status = apr_dir_open (&this_dir, path_native->data, pool);
   if (status) 
     return
       svn_error_createf (status, 0, NULL, pool,
@@ -998,18 +1058,21 @@
         continue;
       else
         {
-          const char *name = apr_pstrdup (pool, this_entry.name);
+          svn_stringbuf_t *name;
+
+          SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (this_entry.name,
+                                                      &name, pool));
           
           if (this_entry.filetype == APR_REG)
-            apr_hash_set (*dirents, name, APR_HASH_KEY_STRING,
+            apr_hash_set (*dirents, name->data, APR_HASH_KEY_STRING,
                           &static_svn_node_file);
           else if (this_entry.filetype == APR_DIR)
-            apr_hash_set (*dirents, name, APR_HASH_KEY_STRING,
+            apr_hash_set (*dirents, name->data, APR_HASH_KEY_STRING,
                           &static_svn_node_dir);
           else
             /* ### symlinks, etc. will fall into this category for now.
                someday subversion will recognize them. :)  */
-            apr_hash_set (*dirents, name, APR_HASH_KEY_STRING,
+            apr_hash_set (*dirents, name->data, APR_HASH_KEY_STRING,
                           &static_svn_node_unknown);
         }
     }
@@ -1047,7 +1110,9 @@
   apr_proc_t cmd_proc;
   apr_procattr_t *cmdproc_attr;
   apr_exit_why_e exitwhy_val;
-  int exitcode_val;
+  int exitcode_val, num_args;
+  const char **args_native;
+  svn_stringbuf_t *cmd_native;
 
   /* Create the process attributes. */
   apr_err = apr_procattr_create (&cmdproc_attr, pool); 
@@ -1070,7 +1135,9 @@
   /* Set the process's working directory. */
   if (path)
     {
-      apr_err = apr_procattr_dir_set (cmdproc_attr, path);
+      svn_stringbuf_t *path_native;
+      SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+      apr_err = apr_procattr_dir_set (cmdproc_attr, path_native->data);
       if (apr_err)
         return svn_error_createf 
           (apr_err, 0, NULL, pool,
@@ -1111,8 +1178,21 @@
            cmd);
     }
 
+  /* Convert cmd and args from UTF-8 */
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (cmd, &cmd_native, pool));
+  for (num_args = 0; args[num_args]; num_args++);
+  args_native = apr_palloc(pool, (num_args + 1) * sizeof(char *));
+  args_native[num_args] = NULL;
+  while (num_args--) {
+    svn_stringbuf_t *arg_native;
+    SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (args[num_args], &arg_native,
+                                                  pool));
+    args_native[num_args] = arg_native->data;
+  }
+
   /* Start the cmd command. */ 
-  apr_err = apr_proc_create (&cmd_proc, cmd, args, NULL, cmdproc_attr, pool);
+  apr_err = apr_proc_create (&cmd_proc, cmd_native->data, args_native, NULL,
+                             cmdproc_attr, pool);
   if (apr_err)
     return svn_error_createf 
       (apr_err, 0, NULL, pool,
@@ -1166,6 +1246,7 @@
   int i; 
   int exitcode;
   int nargs = 4; /* the diff command itself, two paths, plus a trailing NULL */
+  svn_stringbuf_t *diff_utf8;
 
   apr_pool_t *subpool = svn_pool_create (pool);
 
@@ -1206,7 +1287,10 @@
 
   assert (i == nargs);
 
-  SVN_ERR (svn_io_run_cmd (dir, SVN_CLIENT_DIFF, args, pexitcode, NULL, FALSE, 
+  SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (SVN_CLIENT_DIFF, &diff_utf8,
+                                              pool));
+
+  SVN_ERR (svn_io_run_cmd (dir, diff_utf8->data, args, pexitcode, NULL, FALSE, 
                            NULL, outfile, errfile, subpool));
 
   if (*pexitcode < 0 || *pexitcode > 2)
@@ -1233,6 +1317,7 @@
                   apr_pool_t *pool)
 {
   const char *args[14];
+  svn_stringbuf_t *diff3_utf8;
 
   /* Labels fall back to sensible defaults if not specified. */
   if (mine_label == NULL)
@@ -1269,8 +1354,11 @@
   args[12] = NULL;
 #endif
 
+  SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (SVN_CLIENT_DIFF3, &diff3_utf8,
+                                              pool));
+
   /* Run diff3, output the merged text into the scratch file. */
-  SVN_ERR (svn_io_run_cmd (dir, SVN_CLIENT_DIFF3, args, 
+  SVN_ERR (svn_io_run_cmd (dir, diff3_utf8->data, args, 
                            exitcode, NULL, 
                            FALSE, /* clean environment */
                            NULL, merged, NULL,
@@ -1306,6 +1394,7 @@
   apr_status_t apr_err;
   unsigned char block[1024];
   apr_size_t amt_read = sizeof (block);
+  svn_stringbuf_t *path_native;
 
 
   /* Default return value is NULL. */
@@ -1318,7 +1407,9 @@
                               "Can't detect mimetype of non-file '%s'",
                               file);
 
-  apr_err = apr_file_open (&fh, file, APR_READ, 0, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (file, &path_native, pool));
+
+  apr_err = apr_file_open (&fh, path_native->data, APR_READ, 0, pool);
   if (apr_err)
     return svn_error_createf (apr_err, 0, NULL, pool,
                               "svn_io_detect_mimetype: error opening '%s'",
Index: ./subversion/libsvn_subr/svn_error.c
===================================================================
--- ./subversion/libsvn_subr/svn_error.c
+++ ./subversion/libsvn_subr/svn_error.c	Thu May 16 17:29:49 2002
@@ -29,6 +29,7 @@
 #include "svn_pools.h"
 #include "svn_error.h"
 #include "svn_io.h"
+#include "svn_utf.h"
 
 /* Key for the error pool itself. */
 static const char SVN_ERROR_POOL[] = "svn-error-pool";
@@ -314,14 +315,16 @@
 void
 svn_handle_error (svn_error_t *err, FILE *stream, svn_boolean_t fatal)
 {
-  char buf[200];
+  char buf[200], buf2[200];
 
   /* Pretty-print the error */
   /* Note: we can also log errors here someday. */
 
 #ifdef SVN_DEBUG
   if (err->file)
-    fprintf (stream, "\n%s:%ld\n", err->file, err->line);
+    fprintf (stream, "\n%s:%ld\n",
+             svn_utf_utf8_to_native (err->file, buf2, sizeof (buf2)),
+             err->line);
   else
     fprintf (stream, "\n%s\n", SVN_FILE_LINE_UNDEFINED);
 #else
@@ -332,7 +335,9 @@
   if ((err->apr_err > APR_OS_START_USEERR) 
       && (err->apr_err <= APR_OS_START_CANONERR))
     fprintf (stream, "svn_error: #%d : <%s>\n", err->apr_err,
-             svn_strerror (err->apr_err, buf, sizeof (buf)));
+             svn_utf_utf8_to_native (svn_strerror (err->apr_err,
+                                                   buf, sizeof (buf)),
+                                     buf2, sizeof(buf2)));
 
   /* Otherwise, this must be an APR error code. */
   else
@@ -342,7 +347,8 @@
              apr_strerror (err->apr_err, buf, sizeof(buf)));
 
   if (err->message)
-    fprintf (stream, "  %s", err->message);
+     fprintf (stream, "  %s",
+              svn_utf_utf8_to_native (err->message, buf2, sizeof(buf2)));
 
   fputc ('\n', stream);
   fflush (stream);
@@ -361,12 +367,22 @@
 {
   va_list ap;
 
+  apr_pool_t *pool = svn_pool_create (NULL);
+  svn_stringbuf_t *msg, *msg_utf8;
+  svn_error_t *err;
+
   va_start (ap, fmt);
-  vfprintf (stderr, fmt, ap);
+  msg_utf8 = svn_stringbuf_create (apr_pvsprintf (pool, fmt, ap), pool);
   va_end (ap);
 
-  fprintf (stderr, "\n");
+  err = svn_utf_stringbuf_from_utf8 (msg_utf8, &msg, pool);
+  if (err)
+    svn_handle_error (err, stderr, FALSE);
+  else
+    fprintf (stderr, "%s\n", msg->data);
   fflush (stderr);
+
+  svn_pool_destroy (pool);
 }
 
 
Index: ./subversion/libsvn_client/auth.c
===================================================================
--- ./subversion/libsvn_client/auth.c
+++ ./subversion/libsvn_client/auth.c	Wed May 22 21:38:21 2002
@@ -32,6 +32,7 @@
 #include "svn_error.h"
 #include "svn_io.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 
 #include "client.h"
 
@@ -99,7 +100,8 @@
           apr_uid_t uid;
           apr_gid_t gid;
           apr_status_t status;
-          
+          svn_stringbuf_t *un_utf8;
+
           status = apr_current_userid (&uid, &gid, pool);
           if (status)
             return 
@@ -110,7 +112,9 @@
           if (status)
             return svn_error_create(status, 0, NULL, pool,
                                     "Error in UID->username.");
-          *username = un;                       
+
+          SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (un, &un_utf8, pool));
+          *username = un_utf8->data;
         }
 
       /* Store a copy of the username in the auth_baton too. */
Index: ./subversion/libsvn_client/checkout.c
===================================================================
--- ./subversion/libsvn_client/checkout.c
+++ ./subversion/libsvn_client/checkout.c	Wed May 22 21:03:32 2002
@@ -30,6 +30,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 #include "client.h"
 
 
@@ -227,9 +228,13 @@
       apr_file_t *in = NULL;
       void *wrap_edit_baton;
       const svn_delta_edit_fns_t *wrap_editor;
+      svn_stringbuf_t *xml_src_native;
+
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (xml_src, &xml_src_native, pool));
 
       /* Open xml file. */
-      apr_err = apr_file_open (&in, xml_src->data, (APR_READ | APR_CREATE),
+      apr_err = apr_file_open (&in, xml_src_native->data,
+                               (APR_READ | APR_CREATE),
                                APR_OS_DEFAULT, pool);
       if (apr_err)
         return svn_error_createf (apr_err, 0, NULL, pool,
Index: ./subversion/libsvn_client/diff.c
===================================================================
--- ./subversion/libsvn_client/diff.c
+++ ./subversion/libsvn_client/diff.c	Wed May 22 22:10:56 2002
@@ -34,6 +34,7 @@
 #include "svn_test.h"
 #include "svn_io.h"
 #include "svn_pools.h"
+#include "svn_utf.h"
 #include "client.h"
 #include <assert.h>
 
@@ -53,8 +54,11 @@
                     apr_pool_t *pool)
 {
   int i;
+  svn_stringbuf_t *path_native;
 
-  apr_file_printf (file, "\nProperty changes on: %s\n", path);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+
+  apr_file_printf (file, "\nProperty changes on: %s\n", path_native->data);
   apr_file_printf (file, 
      "___________________________________________________________________\n");
 
@@ -64,6 +68,7 @@
         = &APR_ARRAY_IDX(propchanges, i, svn_prop_t);
 
       const svn_stringbuf_t *original_value;
+      svn_stringbuf_t *propname_native, *propold_native, *propnew_native;
 
       if (original_props)
         original_value =
@@ -71,13 +76,21 @@
       else
         original_value = NULL;
       
-      apr_file_printf (file, "Name: %s\n", propchange->name);
-
-      if (original_value != NULL)
-        apr_file_printf (file, "   - %s\n", original_value->data);
-
-      if (propchange->value != NULL)
-        apr_file_printf (file, "   + %s\n", propchange->value->data);
+      SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (propchange->name,
+                                                    &propname_native, pool));
+      apr_file_printf (file, "Name: %s\n", propname_native->data);
+
+      if (original_value != NULL) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (original_value, &propold_native,
+                                              pool));
+        apr_file_printf (file, "   - %s\n", propold_native->data);
+      }
+
+      if (propchange->value != NULL) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8_string (propchange->value,
+                                                     &propnew_native, pool));
+        apr_file_printf (file, "   + %s\n", propnew_native->data);
+      }
     }
 
   apr_file_printf (file, "\n");
@@ -119,6 +132,7 @@
   apr_file_t *errfile = diff_cmd_baton->errfile;
   apr_pool_t *subpool = svn_pool_create (diff_cmd_baton->pool);
   const char *label = path;
+  svn_stringbuf_t *label_native;
 
   /* Execute local diff command on these two paths, print to stdout. */
   nargs = diff_cmd_baton->options->nelts;
@@ -135,7 +149,9 @@
     }
 
   /* Print out the diff header. */
-  apr_file_printf (outfile, "Index: %s\n", label ? label : tmpfile1);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (label ? label : tmpfile1,
+                                                &label_native, subpool));
+  apr_file_printf (outfile, "Index: %s\n", label_native->data);
   apr_file_printf (outfile, 
      "===================================================================\n");
 
Index: ./subversion/libsvn_client/copy.c
===================================================================
--- ./subversion/libsvn_client/copy.c
+++ ./subversion/libsvn_client/copy.c	Wed May 22 21:49:51 2002
@@ -30,6 +30,7 @@
 #include "svn_pools.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 #include "client.h"
 
 
@@ -755,9 +756,12 @@
       svn_revnum_t fetched_rev = 0;
       apr_hash_t *props;
       apr_hash_index_t *hi;
+      svn_stringbuf_t *dst_path_native;
       
       /* Open DST_PATH for writing. */
-      status = apr_file_open (&fp, dst_path->data, (APR_CREATE | APR_WRITE),
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (dst_path, &dst_path_native, pool));
+      status = apr_file_open (&fp, dst_path_native->data,
+                              (APR_CREATE | APR_WRITE),
                               APR_OS_DEFAULT, pool);
       if (status)
         return svn_error_createf (status, 0, NULL, pool,
Index: ./subversion/libsvn_client/apply_edits.c
===================================================================
--- ./subversion/libsvn_client/apply_edits.c
+++ ./subversion/libsvn_client/apply_edits.c	Wed May 22 20:56:43 2002
@@ -29,6 +29,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 #include "client.h"
 
 
@@ -128,12 +129,14 @@
   svn_error_t *err;
   apr_status_t apr_err;
   apr_file_t *in = NULL;
+  svn_stringbuf_t *xml_src_native;
 
   assert (path != NULL);
   assert (xml_src != NULL);
 
   /* Open the XML source file. */
-  apr_err = apr_file_open (&in, xml_src->data,
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (xml_src, &xml_src_native, pool));
+  apr_err = apr_file_open (&in, xml_src_native->data,
                       (APR_READ | APR_CREATE),
                       APR_OS_DEFAULT,
                       pool);
Index: ./subversion/libsvn_client/repos_diff.c
===================================================================
--- ./subversion/libsvn_client/repos_diff.c
+++ ./subversion/libsvn_client/repos_diff.c	Wed May 22 23:33:29 2002
@@ -32,6 +32,7 @@
 #include "svn_wc.h"
 #include "svn_pools.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 
 #include "client.h"
 
@@ -135,7 +136,7 @@
 /* Data used by the apr pool temp file cleanup handler */
 struct temp_file_cleanup_s {
   /* The path to the file to be deleted */
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* Note: _not_ UTF-8! */
   /* The pool to which the deletion of the file is linked. */
   apr_pool_t *pool;
 };
@@ -194,6 +195,7 @@
 {
   struct temp_file_cleanup_s *s = arg;
 
+  /* This is ok, path has already been de-UTF-8-ized. */
   return apr_file_remove (s->path->data, s->pool);
 }
 
@@ -224,7 +226,7 @@
                             apr_pool_t *pool)
 {
   struct temp_file_cleanup_s *s = apr_palloc (pool, sizeof (*s));
-  s->path = path;
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &s->path, pool));
   s->pool = pool;
   apr_pool_cleanup_register (s->pool, s, temp_file_plain_cleanup_handler,
                              temp_file_child_cleanup_handler);
@@ -525,9 +527,14 @@
 {
   struct file_baton *b = file_baton;
   apr_status_t status;
+  svn_stringbuf_t *path_start_revision_native, *path_end_revision_native;
+
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (b->path_start_revision,
+                                        &path_start_revision_native, b->pool));
 
   /* Open the file to be used as the base for second revision */
-  status = apr_file_open (&b->file_start_revision, b->path_start_revision->data,
+  status = apr_file_open (&b->file_start_revision,
+                          path_start_revision_native->data,
                           APR_READ, APR_OS_DEFAULT, b->pool);
   if (status)
     return svn_error_createf (status, 0, NULL, b->pool,
@@ -538,7 +545,9 @@
      text delta, it starts empty */
   SVN_ERR (create_empty_file (&b->path_end_revision, b->pool));
   SVN_ERR (temp_file_cleanup_register (b->path_end_revision, b->pool));
-  status = apr_file_open (&b->file_end_revision, b->path_end_revision->data,
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (b->path_end_revision,
+                                        &path_end_revision_native, b->pool));
+  status = apr_file_open (&b->file_end_revision, path_end_revision_native->data,
                           APR_WRITE, APR_OS_DEFAULT, b->pool);
   if (status)
     return svn_error_createf (status, 0, NULL, b->pool,
Index: ./subversion/libsvn_client/update.c
===================================================================
--- ./subversion/libsvn_client/update.c
+++ ./subversion/libsvn_client/update.c	Wed May 22 22:56:04 2002
@@ -29,6 +29,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 #include "client.h"
 
 
@@ -181,9 +182,13 @@
     {
       apr_status_t apr_err;
       apr_file_t *in = NULL;
+      svn_stringbuf_t *xml_src_native;
+
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (xml_src, &xml_src_native, pool));
 
       /* Open xml file. */
-      apr_err = apr_file_open (&in, xml_src->data, (APR_READ | APR_CREATE),
+      apr_err = apr_file_open (&in, xml_src_native->data,
+                               (APR_READ | APR_CREATE),
                                APR_OS_DEFAULT, pool);
       if (apr_err)
         return svn_error_createf (apr_err, 0, NULL, pool,
Index: ./subversion/libsvn_client/commit_util.c
===================================================================
--- ./subversion/libsvn_client/commit_util.c
+++ ./subversion/libsvn_client/commit_util.c	Wed May 22 21:26:47 2002
@@ -30,6 +30,7 @@
 #include "svn_pools.h"
 #include "svn_wc.h"
 #include "svn_sorts.h"
+#include "svn_utf.h"
 
 #include <assert.h>
 #include <stdlib.h>  /* for qsort() */
@@ -1080,6 +1081,7 @@
 struct edit_baton
 {
   const char *path;
+  apr_pool_t *pool;
 };
 
 
@@ -1089,6 +1091,7 @@
   struct edit_baton *new_baton 
     = apr_pcalloc (pool, sizeof (struct edit_baton *));
   new_baton->path = apr_pstrdup (pool, path);
+  new_baton->pool = pool;
   return ((void *) new_baton);
 }
 
@@ -1113,7 +1116,9 @@
           apr_pool_t *pool,
           void **baton)
 {
-  printf ("   Adding  : %s\n", path);
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+  printf ("   Adding  : %s\n", path_native->data);
   *baton = make_baton (path, pool);
   return SVN_NO_ERROR;
 }
@@ -1124,7 +1129,9 @@
               void *parent_baton,
               apr_pool_t *pool)
 {
-  printf ("   Deleting: %s\n", path);
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+  printf ("   Deleting: %s\n", path_native->data);
   return SVN_NO_ERROR;
 }
 
@@ -1135,7 +1142,9 @@
            apr_pool_t *pool,
            void **baton)
 {
-  printf ("   Opening : %s\n", path);
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path, &path_native, pool));
+  printf ("   Opening : %s\n", path_native->data);
   *baton = make_baton (path, pool);
   return SVN_NO_ERROR;
 }
@@ -1144,7 +1153,10 @@
 close_item (void *baton)
 {
   struct edit_baton *this = baton;
-  printf ("   Closing : %s\n", this->path);
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (this->path, &path_native,
+                                                this->pool));
+  printf ("   Closing : %s\n", path_native->data);
   return SVN_NO_ERROR;
 }
 
@@ -1155,7 +1167,12 @@
              const svn_string_t *value,
              apr_pool_t *pool)
 {
-  printf ("      PropSet (%s=%s)\n", name, value ? value->data : "");
+  svn_stringbuf_t *name_native, *value_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (name, &name_native, pool));
+  if (value)
+    SVN_ERR (svn_utf_stringbuf_from_utf8 (value, &value_native, pool));
+  printf ("      PropSet (%s=%s)\n", name_native->data,
+          value ? value_native->data : "");
   return SVN_NO_ERROR;
 }
 
Index: ./subversion/libsvn_client/add.c
===================================================================
--- ./subversion/libsvn_client/add.c
+++ ./subversion/libsvn_client/add.c	Wed May 22 21:37:28 2002
@@ -29,6 +29,7 @@
 #include "svn_pools.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 #include "client.h"
 
 
@@ -46,6 +47,7 @@
   apr_status_t apr_err;
   apr_pool_t *subpool;
   apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME;
+  svn_stringbuf_t *dirname_native;
 
   /* Add this directory to revision control. */
   SVN_ERR (svn_wc_add (svn_stringbuf_create (dirname, pool),
@@ -57,12 +59,14 @@
 
   /* Read the directory entries one by one and add those things to
      revision control. */
-  apr_err = apr_dir_open (&dir, dirname, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (dirname, &dirname_native,
+                                                pool));
+  apr_err = apr_dir_open (&dir, dirname_native->data, pool);
   for (apr_err = apr_dir_read (&this_entry, flags, dir);
        apr_err == APR_SUCCESS;
        apr_err = apr_dir_read (&this_entry, flags, dir))
     {
-      svn_stringbuf_t *fullpath;
+      svn_stringbuf_t *fullpath, *entry_utf8;
 
       /* Skip over SVN admin directories. */
       if (strcmp (this_entry.name, SVN_WC_ADM_DIR_NAME) == 0)
@@ -75,9 +79,9 @@
 
       /* Construct the full path of the entry. */
       fullpath = svn_stringbuf_create (dirname, subpool);
-      svn_path_add_component 
-        (fullpath,
-         svn_stringbuf_create (this_entry.name, subpool));
+      SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (this_entry.name,
+                                                  &entry_utf8, subpool));
+      svn_path_add_component (fullpath, entry_utf8);
 
       if (this_entry.filetype == APR_DIR)
         /* Recurse. */
@@ -149,6 +153,7 @@
                   apr_pool_t *pool)
 {
   svn_string_t path_str;
+  svn_stringbuf_t *path_native;
   apr_status_t apr_err;
 
   path_str.data = path->data;
@@ -236,7 +241,8 @@
     }
 
   /* This is a regular "mkdir" + "svn add" */
-  apr_err = apr_dir_make (path->data, APR_OS_DEFAULT, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+  apr_err = apr_dir_make (path_native->data, APR_OS_DEFAULT, pool);
   if (apr_err)
     return svn_error_create (apr_err, 0, NULL, pool, path->data);
   
Index: ./subversion/libsvn_client/commit.c
===================================================================
--- ./subversion/libsvn_client/commit.c
+++ ./subversion/libsvn_client/commit.c	Wed May 22 21:09:21 2002
@@ -35,6 +35,7 @@
 #include "svn_path.h"
 #include "svn_test.h"
 #include "svn_io.h"
+#include "svn_utf.h"
 
 #include "client.h"
 
@@ -61,9 +62,12 @@
   void *handler_baton;
   apr_file_t *f = NULL;
   apr_status_t apr_err;
+  svn_stringbuf_t *path_native;
 
   /* Get an apr file for PATH. */
-  apr_err = apr_file_open (&f, path->data, APR_READ, APR_OS_DEFAULT, pool);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+  apr_err = apr_file_open (&f, path_native->data, APR_READ, APR_OS_DEFAULT,
+                           pool);
   if (apr_err)
     return svn_error_createf (apr_err, 0, NULL, pool, 
                               "error opening `%s' for reading", path->data);
@@ -146,9 +150,10 @@
   apr_finfo_t finfo;
   apr_status_t apr_err;
   apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME;
-  svn_stringbuf_t *this_path, *this_edit_path;
+  svn_stringbuf_t *this_path, *this_edit_path, *path_native;
 
-  if ((apr_err = apr_dir_open (&dir, path->data, pool)))
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (path, &path_native, pool));
+  if ((apr_err = apr_dir_open (&dir, path_native->data, pool)))
     return svn_error_createf (apr_err, 0, NULL, pool, 
                               "unable to open directory %s", path->data);
 
@@ -159,7 +164,7 @@
        apr_err == APR_SUCCESS;
        svn_pool_clear (subpool), apr_err = apr_dir_read (&finfo, flags, dir))
     {
-      svn_stringbuf_t *name;
+      svn_stringbuf_t *name, *name_utf8;
 
       if (finfo.filetype == APR_DIR)
         {
@@ -184,8 +189,9 @@
       /* Make a stringbuf version of the entry name, and append it as
          a path component to THIS_PATH and THIS_EDIT_PATH. */
       name = svn_stringbuf_create (finfo.name, subpool);
-      svn_path_add_component (this_path, name);
-      svn_path_add_component (this_edit_path, name);
+      SVN_ERR (svn_utf_stringbuf_to_utf8 (name, &name_utf8, subpool));
+      svn_path_add_component (this_path, name_utf8);
+      svn_path_add_component (this_edit_path, name_utf8);
 
       /* We only import subdirectories when we're doing a regular
          recursive import. */
@@ -219,9 +225,9 @@
       
       /* Hack THIS_PATH and THIS_EDIT_PATH back to their original sizes. */
       svn_stringbuf_chop (this_path, 
-                          (path->len ? name->len + 1 : name->len));
+                          (path->len ? name_utf8->len + 1 : name_utf8->len));
       svn_stringbuf_chop (this_edit_path, 
-                          (edit_path->len ? name->len + 1 : name->len));
+                          (edit_path->len ? name_utf8->len + 1 : name_utf8->len));
     }
 
   /* Check that the loop exited cleanly. */
@@ -360,9 +366,13 @@
                 apr_pool_t *pool)
 {
   apr_status_t apr_err;
+  svn_stringbuf_t *xml_file_native;
 
   /* Open the xml file for writing. */
-  if ((apr_err = apr_file_open (xml_hnd, xml_file, (APR_WRITE | APR_CREATE),
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (xml_file, &xml_file_native,
+                                                pool));
+  if ((apr_err = apr_file_open (xml_hnd, xml_file_native->data,
+                                (APR_WRITE | APR_CREATE),
                                 APR_OS_DEFAULT, pool)))
     return svn_error_createf (apr_err, 0, NULL, pool, 
                               "error opening %s", xml_file);
Index: ./subversion/clients/cmdline/props.c
===================================================================
--- ./subversion/clients/cmdline/props.c
+++ ./subversion/clients/cmdline/props.c	Wed May 22 19:03:34 2002
@@ -29,12 +29,13 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
 
 
-void
+svn_error_t *
 svn_cl__print_prop_hash (apr_hash_t *prop_hash,
                          apr_pool_t *pool)
 {
@@ -45,20 +46,25 @@
       const void *key;
       apr_ssize_t klen;
       void *val;
-      
+
       svn_stringbuf_t *propkey, *propval;
+      svn_stringbuf_t *propkey_native, *propval_native;
 
       /* Get next property */
       apr_hash_this (hi, &key, &klen, &val);
       propkey = svn_stringbuf_ncreate (key, klen, pool);
       propval = (svn_stringbuf_t *) val;
 
-      printf ("  %s : %s\n", propkey->data, propval->data);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (propkey, &propkey_native, pool));
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (propval, &propval_native, pool));
+
+      printf ("  %s : %s\n", propkey_native->data, propval_native->data);
     } 
+  return SVN_NO_ERROR;
 }
 
 
-void
+svn_error_t *
 svn_cl__print_prop_names (apr_hash_t *prop_hash,
                           apr_pool_t *pool)
 {
@@ -70,13 +76,17 @@
       apr_ssize_t klen;
       
       svn_stringbuf_t *propkey;
+      svn_stringbuf_t *propkey_native;
 
       /* Get next property */
       apr_hash_this (hi, &key, &klen, NULL);
       propkey = svn_stringbuf_ncreate (key, klen, pool);
 
-      printf ("  %s\n", propkey->data);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (propkey, &propkey_native, pool));
+
+      printf ("  %s\n", propkey_native->data);
     } 
+  return SVN_NO_ERROR;
 }
 
 
Index: ./subversion/clients/cmdline/cl.h
===================================================================
--- ./subversion/clients/cmdline/cl.h
+++ ./subversion/clients/cmdline/cl.h	Wed May 22 21:30:25 2002
@@ -69,9 +69,9 @@
 
   svn_stringbuf_t *message;  /* log message */
 
-  svn_stringbuf_t *xml_file;  /* F in "svn blah --xml-file F" */
+  svn_stringbuf_t *xml_file;  /* F in "svn blah --xml-file F" */ /* UTF-8! */
 
-  svn_stringbuf_t *target;  /* Target dir, T in "svn co -d T" */
+  svn_stringbuf_t *target;  /* Target dir, T in "svn co -d T" */ /* UTF-8! */
 
   svn_stringbuf_t *ancestor_path;  /* ### todo: who sets this? */
 
@@ -88,13 +88,13 @@
   svn_boolean_t verbose;
   svn_boolean_t very_verbose;
   svn_boolean_t update;
-  apr_array_header_t *args;
+  apr_array_header_t *args;      /* UTF-8! */
   svn_stringbuf_t *filedata;
   svn_boolean_t help;
-  svn_stringbuf_t *auth_username;
-  svn_stringbuf_t *auth_password;
+  svn_stringbuf_t *auth_username; /* UTF-8! */
+  svn_stringbuf_t *auth_password; /* UTF-8! */
   svn_stringbuf_t *extensions;   /* for extension args to subprocesses */
-  apr_array_header_t *targets;   /* when target list supplied from file */
+  apr_array_header_t *targets;   /* when target list supplied from file */ /* UTF-8! */
   svn_boolean_t xml;             /* output in xml, e.g., "svn log --xml" */
 } svn_cl__opt_state_t;
 
@@ -177,6 +177,8 @@
   found, it will overwrite the value of opt_state->start_revision.  If
   a second one is found, it will overwrite opt_state->end_revision.
   (Extra revisions beyond that are ignored.)
+
+   The array of targets will be in UTF-8 format.
   */
 apr_array_header_t*
 svn_cl__args_to_target_array (apr_getopt_t *os,
@@ -184,13 +186,17 @@
                               svn_boolean_t extract_revisions,
                               apr_pool_t *pool);
 
-/* Splits a list of whitespace-separated values into an apr_array_header_t */
-apr_array_header_t*
-svn_cl__stringlist_to_array (svn_stringbuf_t *buffer, apr_pool_t *pool);
-
-/* Splits a list of newline seperated values into an apr_array_header_t */
-apr_array_header_t*
-svn_cl__newlinelist_to_array (svn_stringbuf_t *buffer, apr_pool_t *pool);
+/* Splits a list of whitespace-separated values into an apr_array_header_t
+   (List will be in UTF-8 format.) */
+svn_error_t*
+svn_cl__stringlist_to_array (apr_array_header_t **result,
+                             svn_stringbuf_t *buffer, apr_pool_t *pool);
+
+/* Splits a list of newline seperated values into an apr_array_header_t
+   (List will be in UTF-8 format.) */
+svn_error_t*
+svn_cl__newlinelist_to_array (apr_array_header_t **result,
+                              svn_stringbuf_t *buffer, apr_pool_t *pool);
 
 void svn_cl__push_implicit_dot_target (apr_array_header_t *targets,
                                        apr_pool_t *pool);
@@ -264,11 +270,13 @@
 
 /* Print a hash that maps property names (char *) to property values
    (svn_stringbuf_t *). */
-void svn_cl__print_prop_hash (apr_hash_t *prop_hash, apr_pool_t *pool);
+svn_error_t *
+svn_cl__print_prop_hash (apr_hash_t *prop_hash, apr_pool_t *pool);
 
 /* Print out the property names in a hash that maps property names (char *) 
    to property values (svn_stringbuf_t *). */
-void svn_cl__print_prop_names (apr_hash_t *prop_hash, apr_pool_t *pool);
+svn_error_t *
+svn_cl__print_prop_names (apr_hash_t *prop_hash, apr_pool_t *pool);
 
 /* Returns an editor that prints out events in an update or checkout.
    The IS_CHECKOUT boolean tells the editor what kind of final
@@ -277,7 +285,7 @@
 svn_error_t *
 svn_cl__get_trace_update_editor (const svn_delta_editor_t **editor,
                                  void **edit_baton,
-                                 svn_stringbuf_t *initial_path,
+                                 svn_stringbuf_t *initial_path /* UTF-8! */,
                                  svn_boolean_t is_checkout,
                                  svn_boolean_t suppress_final_line,
                                  apr_pool_t *pool);
Index: ./subversion/clients/cmdline/propdel-cmd.c
===================================================================
--- ./subversion/clients/cmdline/propdel-cmd.c
+++ ./subversion/clients/cmdline/propdel-cmd.c	Wed May 22 18:23:20 2002
@@ -28,6 +28,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -60,10 +61,14 @@
       SVN_ERR (svn_client_propset (pname->data, NULL, target->data,
                                    opt_state->recursive, pool));
 
-      if (! opt_state->quiet)
-        printf ("property `%s' deleted %s from '%s'.\n", pname->data,
+      if (! opt_state->quiet) {
+        svn_stringbuf_t *pname_native, *target_native;
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (pname, &pname_native, pool));
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (target, &target_native, pool));
+        printf ("property `%s' deleted %s from '%s'.\n", pname_native->data,
                 opt_state->recursive ? "(recursively)" : "",
-                target->data);
+                target_native->data);
+      }
     }
 
   return SVN_NO_ERROR;
Index: ./subversion/clients/cmdline/diff-cmd.c
===================================================================
--- ./subversion/clients/cmdline/diff-cmd.c
+++ ./subversion/clients/cmdline/diff-cmd.c	Wed May 22 21:29:20 2002
@@ -48,7 +48,7 @@
   int i;
 
   auth_baton = svn_cl__make_auth_baton (opt_state, pool);
-  options = svn_cl__stringlist_to_array (opt_state->extensions, pool);
+  SVN_ERR (svn_cl__stringlist_to_array (&options, opt_state->extensions, pool));
 
   /* Get an apr_file_t representing stdout and stderr, which is where
      we'll have the external 'diff' program print to. */
Index: ./subversion/clients/cmdline/util.c
===================================================================
--- ./subversion/clients/cmdline/util.c
+++ ./subversion/clients/cmdline/util.c	Wed May 22 21:39:45 2002
@@ -41,6 +41,7 @@
 #include "svn_error.h"
 #include "svn_io.h"
 #include "svn_pools.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -57,6 +58,18 @@
     = svn_stringbuf_create (str, pool);
 }
 
+/* Same as above, but make UTF-8 while we're at it */
+static svn_error_t *
+array_push_svn_stringbuf_utf8 (apr_array_header_t *array,
+                               const char *str,
+                               apr_pool_t *pool)
+{
+  svn_stringbuf_t *buf;
+  SVN_ERR (svn_utf_cstring_to_utf8_stringbuf (str, &buf, pool));
+  (*((svn_stringbuf_t **) apr_array_push (array))) = buf;
+  return SVN_NO_ERROR;
+}
+
 
 /* Some commands take an implicit "." string argument when invoked
  * with no arguments. Those commands make use of this function to
@@ -94,7 +107,8 @@
           return svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, 
                                    0, 0, pool, "");
         }
-      array_push_svn_stringbuf (opt_state->args, os->argv[os->ind++], pool);
+      SVN_ERR (array_push_svn_stringbuf_utf8 (opt_state->args,
+                                              os->argv[os->ind++], pool));
     }
 
   return SVN_NO_ERROR;
@@ -120,7 +134,8 @@
 
   while (os->ind < os->argc)
     {
-      array_push_svn_stringbuf (opt_state->args, os->argv[os->ind++], pool);
+      SVN_ERR (array_push_svn_stringbuf_utf8 (opt_state->args,
+                                              os->argv[os->ind++], pool));
     }
 
   return SVN_NO_ERROR;
@@ -141,7 +156,7 @@
 static svn_error_t *
 parse_path (svn_client_revision_t *rev,
             svn_stringbuf_t **truepath,
-            svn_stringbuf_t *path,
+            svn_stringbuf_t *path /* UTF-8! */,
             apr_pool_t *pool)
 {
   int i;
@@ -154,11 +169,16 @@
     {
       if (path->data[i] == '@')
         {
-          if (svn_cl__parse_revision (os, path->data + i + 1, subpool))
+          svn_stringbuf_t *native_rev;
+
+          SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (path->data + i + 1,
+                                                        &native_rev, subpool));
+
+          if (svn_cl__parse_revision (os, native_rev->data, subpool))
             return svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR,
                                       0, NULL, subpool,
                                       "Syntax error parsing revision \"%s\"",
-                                      path->data + 1);
+                                      path->data + i + 1);
 
           *truepath = svn_stringbuf_ncreate (path->data, i, pool);
           rev->kind = os->start_revision.kind;
@@ -197,6 +217,9 @@
       svn_stringbuf_t *target = svn_stringbuf_create (os->argv[os->ind], pool);
       svn_string_t tstr;
 
+      /* Fixme: need to handle errors here... */
+      svn_utf_stringbuf_to_utf8 (target, &target, pool);
+
       /* If this path looks like it would work as a URL in one of the
          currently available RA libraries, we add it unconditionally
          to the target array. */
@@ -278,8 +301,9 @@
 }
 
 /* Convert a whitespace separated list of items into an apr_array_header_t */
-apr_array_header_t*
-svn_cl__stringlist_to_array(svn_stringbuf_t *buffer, apr_pool_t *pool)
+svn_error_t*
+svn_cl__stringlist_to_array(apr_array_header_t **result,
+                            svn_stringbuf_t *buffer, apr_pool_t *pool)
 {
   apr_array_header_t *array = apr_array_make(pool, DEFAULT_ARRAY_SIZE,
                                              sizeof(svn_stringbuf_t *));
@@ -299,18 +323,23 @@
 
           item  = svn_stringbuf_ncreate(&buffer->data[start],
                                           end - start, pool);
+
+          SVN_ERR (svn_utf_stringbuf_to_utf8 (item, &item, pool));
+
           *((svn_stringbuf_t**)apr_array_push(array)) = item;
 
           start = end;
         }
     }
-  return array;
+  *result = array;
+  return SVN_NO_ERROR;
 }
 
 /* Convert a newline seperated list of items into an apr_array_header_t */
 #define IS_NEWLINE(c) (c == '\n' || c == '\r')
-apr_array_header_t*
-svn_cl__newlinelist_to_array(svn_stringbuf_t *buffer, apr_pool_t *pool)
+svn_error_t*
+svn_cl__newlinelist_to_array(apr_array_header_t **result,
+                             svn_stringbuf_t *buffer, apr_pool_t *pool)
 {
   apr_array_header_t *array = apr_array_make(pool, DEFAULT_ARRAY_SIZE,
 					     sizeof(svn_stringbuf_t *));
@@ -339,12 +368,16 @@
 
 	  item = svn_stringbuf_ncreate(&buffer->data[start],
 				       end - start, pool);
+
+          SVN_ERR (svn_utf_stringbuf_to_utf8 (item, &item, pool));
+
 	  *((svn_stringbuf_t**)apr_array_push(array)) = item;
 
 	  start = end;
 	}
     }
-  return array;
+  *result = array;
+  return SVN_NO_ERROR;
 }
 #undef IS_NEWLINE
 
@@ -361,15 +394,15 @@
 
 
 svn_error_t *
-svn_cl__edit_externally (svn_stringbuf_t **edited_contents,
-                         svn_stringbuf_t *base_dir,
-                         const svn_string_t *contents,
+svn_cl__edit_externally (svn_stringbuf_t **edited_contents /* UTF-8! */,
+                         svn_stringbuf_t *base_dir /* UTF-8! */,
+                         const svn_string_t *contents /* UTF-8! */,
                          apr_pool_t *pool)
 {
   const char *editor = NULL;
   const char *cmd;
   apr_file_t *tmp_file;
-  svn_stringbuf_t *tmpfile_name;
+  svn_stringbuf_t *tmpfile_name, *tmpfile_native, *contents_native;
   apr_status_t apr_err, apr_err2;
   apr_size_t written;
   apr_finfo_t finfo_before, finfo_after;
@@ -393,6 +426,10 @@
   /* By now, we had better have an EDITOR to work with. */
   assert (editor);
 
+  /* Convert file contents from UTF-8 */
+  SVN_ERR (svn_utf_stringbuf_from_utf8_string (contents, &contents_native,
+                                               pool));
+
   /* Ask the working copy for a temporary file based on BASE_DIR */
   SVN_ERR (svn_io_open_unique_file 
            (&tmp_file, &tmpfile_name,
@@ -402,15 +439,15 @@
        the file we just created!! ***/
 
   /* Dump initial CONTENTS to TMP_FILE. */
-  apr_err = apr_file_write_full (tmp_file, contents->data, 
-                                 contents->len, &written);
+  apr_err = apr_file_write_full (tmp_file, contents_native->data, 
+                                 contents_native->len, &written);
 
   apr_err2 = apr_file_close (tmp_file);
   if (! apr_err)
     apr_err = apr_err2;
   
   /* Make sure the whole CONTENTS were written, else return an error. */
-  if (apr_err || (written != contents->len))
+  if (apr_err || (written != contents_native->len))
     {
       err = svn_error_createf
         (apr_err ? apr_err : SVN_ERR_INCOMPLETE_DATA, 0, NULL, pool,
@@ -418,9 +455,13 @@
       goto cleanup;
     }
 
+  err = svn_utf_stringbuf_from_utf8 (tmpfile_name, &tmpfile_native, pool);
+  if (err)
+    goto cleanup;
+
   /* Get information about the temporary file before the user has
      been allowed to edit its contents. */
-  apr_err = apr_stat (&finfo_before, tmpfile_name->data, 
+  apr_err = apr_stat (&finfo_before, tmpfile_native->data, 
                       APR_FINFO_MTIME | APR_FINFO_SIZE, pool);
   if (apr_err)
     {
@@ -430,7 +471,7 @@
     }
 
   /* Now, run the editor command line.  */
-  cmd = apr_psprintf (pool, "%s %s", editor, tmpfile_name->data);
+  cmd = apr_psprintf (pool, "%s %s", editor, tmpfile_native->data);
   sys_err = system (cmd);
   if (sys_err != 0)
     {
@@ -442,7 +483,7 @@
     }
   
   /* Get information about the temporary file after the assumed editing. */
-  apr_err = apr_stat (&finfo_after, tmpfile_name->data, 
+  apr_err = apr_stat (&finfo_after, tmpfile_native->data, 
                       APR_FINFO_MTIME | APR_FINFO_SIZE, pool);
   if (apr_err)
     {
@@ -456,6 +497,9 @@
       (finfo_before.size != finfo_after.size))
     {
       err = svn_string_from_file (edited_contents, tmpfile_name->data, pool);
+      if (!err)
+        err = svn_utf_stringbuf_to_utf8 (*edited_contents, edited_contents,
+                                         pool);
       if (err)
         goto cleanup; /* In case more code gets added before cleanup... */
     }
@@ -467,7 +511,7 @@
 
  cleanup:
 
-  apr_err = apr_file_remove (tmpfile_name->data, pool);
+  apr_err = apr_file_remove (tmpfile_native->data, pool);
 
   /* Only report remove error if there was no previous error. */
   if (! err && apr_err)
@@ -481,13 +525,13 @@
 struct log_msg_baton
 {
   svn_stringbuf_t *message;
-  svn_stringbuf_t *base_dir;
+  svn_stringbuf_t *base_dir; /* UTF-8! */
 };
 
 
 void *
 svn_cl__make_log_msg_baton (svn_cl__opt_state_t *opt_state,
-                            svn_stringbuf_t *base_dir,
+                            svn_stringbuf_t *base_dir /* UTF-8! */,
                             apr_pool_t *pool)
 {
   struct log_msg_baton *baton = apr_palloc (pool, sizeof (*baton));
@@ -579,8 +623,7 @@
 
   if (lmb->message)
     {
-      *log_msg = svn_stringbuf_dup (lmb->message, pool);
-      return SVN_NO_ERROR;
+      return svn_utf_stringbuf_to_utf8 (lmb->message, log_msg, pool);
     }
 
   if (! (commit_items || commit_items->nelts))
@@ -655,6 +698,8 @@
 
           for (len = message->len; len >= 0; len--)
             {
+              /* FIXME: should really use an UTF-8 whitespace test
+                 rather than apr_isspace, which is locale dependant */
               if (! apr_isspace (message->data[len]))
                 break;
             }
Index: ./subversion/clients/cmdline/prompt.c
===================================================================
--- ./subversion/clients/cmdline/prompt.c
+++ ./subversion/clients/cmdline/prompt.c	Wed May 22 18:14:32 2002
@@ -28,6 +28,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 #include "apr_lib.h"
@@ -79,6 +80,7 @@
   apr_status_t status;
   apr_file_t *fp;
   char c;
+  svn_stringbuf_t *native_prompt, *utf8_strbuf;
 
   /* ### baton is NULL... the commandline client app doesn't need one,
    but a GUI app probably would. */
@@ -91,6 +93,8 @@
       svn_error_create (status, 0, NULL, pool,
                         "svn_cl__prompt_user:  couldn't open stdin.");
 
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (prompt, &native_prompt, pool));
+
   /* ### implement the HIDE flag later using apr_getpassword or
      something. */
   if (! hide)
@@ -128,7 +132,8 @@
       printf ("\n");
     }
 
-  *result = strbuf->data;
+  SVN_ERR (svn_utf_stringbuf_to_utf8 (strbuf, &utf8_strbuf, pool));
+  *result = utf8_strbuf->data;
 
   return SVN_NO_ERROR;
 }
Index: ./subversion/clients/cmdline/propget-cmd.c
===================================================================
--- ./subversion/clients/cmdline/propget-cmd.c
+++ ./subversion/clients/cmdline/propget-cmd.c	Wed May 22 18:39:03 2002
@@ -28,6 +28,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -76,13 +77,25 @@
         {
           const char * filename; 
           const svn_string_t *propval;
+          svn_stringbuf_t *filename_native, *propval_native;
+
           apr_hash_this(hi, (const void **)&filename, NULL, (void **)&propval);
 
           /* ### this won't handle binary property values */
-          if (print_filenames)
-            printf ("%s - %s\n", filename, propval->data);
-          else
-            printf ("%s\n", propval->data);
+          if (print_filenames) {
+            SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (filename,
+                                                          &filename_native,
+                                                          pool));
+            SVN_ERR (svn_utf_stringbuf_from_utf8_string (propval,
+                                                         &propval_native,
+                                                         pool));
+            printf ("%s - %s\n", filename_native->data, propval_native->data);
+          } else {
+            SVN_ERR (svn_utf_stringbuf_from_utf8_string (propval,
+                                                         &propval_native,
+                                                         pool));
+            printf ("%s\n", propval_native->data);
+          }
         }
     }
 
Index: ./subversion/clients/cmdline/log-cmd.c
===================================================================
--- ./subversion/clients/cmdline/log-cmd.c
+++ ./subversion/clients/cmdline/log-cmd.c	Sun May 19 02:48:20 2002
@@ -33,6 +33,7 @@
 #include "svn_error.h"
 #include "svn_pools.h"
 #include "svn_xml.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -154,6 +155,7 @@
                       apr_pool_t *pool)
 {
   struct log_message_receiver_baton *lb = baton;
+  svn_stringbuf_t *author_native, *date_native, *msg_native;
 
   /* Number of lines in the msg. */
   int lines;
@@ -167,7 +169,11 @@
       return SVN_NO_ERROR;
     }
 
-  humanize_date (dbuf, date);
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (author, &author_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (date, &date_native, pool));
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (msg, &msg_native, pool));
+
+  humanize_date (dbuf, date_native->data);
 
 #define SEP_STRING \
   "------------------------------------------------------------------------\n"
@@ -178,9 +184,9 @@
       lb->first_call = 0;
     }
 
-  lines = num_lines (msg);
+  lines = num_lines (msg_native->data);
   printf ("rev %" SVN_REVNUM_T_FMT ":  %s | %s | %d line%s\n",
-          rev, author, dbuf, lines, (lines > 1) ? "s" : "");
+          rev, author_native->data, dbuf, lines, (lines > 1) ? "s" : "");
   if (changed_paths)
     {
       apr_hash_index_t *hi;
@@ -211,7 +217,7 @@
         }
     }
   printf ("\n");  /* A blank line always precedes the log message. */
-  printf ("%s\n", msg);
+  printf ("%s\n", msg_native->data);
   printf (SEP_STRING);
 
   return SVN_NO_ERROR;
Index: ./subversion/clients/cmdline/status.c
===================================================================
--- ./subversion/clients/cmdline/status.c
+++ ./subversion/clients/cmdline/status.c	Thu May 16 19:55:42 2002
@@ -26,6 +26,7 @@
 #include "svn_sorts.h"
 #include "svn_wc.h"
 #include "svn_string.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -241,6 +242,8 @@
   for (i = 0; i < statusarray->nelts; i++)
     {
       const svn_item_t *item;
+      svn_stringbuf_t *path;
+      svn_error_t *err;
 
       item = &APR_ARRAY_IDX(statusarray, i, const svn_item_t);
       status = item->value;
@@ -248,10 +251,14 @@
       if ((skip_unrecognized) && (! status->entry))
         continue;
 
+      err = svn_utf_stringbuf_from_utf8_cstring (item->key, &path, pool);
+      if (err)
+        svn_handle_error (err, stderr, FALSE);
+
       if (detailed)
-        print_long_format (item->key, show_last_committed, status);
+        print_long_format (path->data, show_last_committed, status);
       else
-        print_short_format (item->key, status);
+        print_short_format (path->data, status);
     }
 
   /* If printing in detailed format, we might have a head revision to
Index: ./subversion/clients/cmdline/help-cmd.c
===================================================================
--- ./subversion/clients/cmdline/help-cmd.c
+++ ./subversion/clients/cmdline/help-cmd.c	Wed May 22 17:02:20 2002
@@ -26,6 +26,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_version.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -35,7 +36,7 @@
 print_version_info (apr_pool_t *pool)
 {
   void *ra_baton;
-  svn_stringbuf_t *descriptions;
+  svn_stringbuf_t *descriptions, *descriptions_native;
   static const char info[] =
     "Copyright (C) 2000-2002 CollabNet.\n"
     "Subversion is open source software, see http://subversion.tigris.org/\n";
@@ -52,7 +53,10 @@
   /* Get a descriptive list of them. */
   SVN_ERR (svn_ra_print_ra_libraries (&descriptions, ra_baton, pool));
 
-  printf ("%s\n", descriptions->data);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (descriptions, &descriptions_native,
+                                        pool));
+
+  printf ("%s\n", descriptions_native->data);
 
   return SVN_NO_ERROR;
 }
@@ -82,7 +86,11 @@
     for (i = 0; i < targets->nelts; i++)
       {
         svn_stringbuf_t *this = (((svn_stringbuf_t **) (targets)->elts))[i];
-	svn_cl__subcommand_help (this->data, pool);
+        svn_stringbuf_t *this_native;
+        /* This is a bit silly, but svn_cl__args_to_target_array()
+           converts the args to UTF-8, so we have to convert them back. */
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (this, &this_native, pool));
+	svn_cl__subcommand_help (this_native->data, pool);
       }
   else if (opt_state && opt_state->version)  /* just -v or --version */
     SVN_ERR (print_version_info (pool));        
Index: ./subversion/clients/cmdline/propset-cmd.c
===================================================================
--- ./subversion/clients/cmdline/propset-cmd.c
+++ ./subversion/clients/cmdline/propset-cmd.c	Wed May 22 18:48:21 2002
@@ -28,6 +28,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -72,11 +73,16 @@
       SVN_ERR (svn_client_propset(propname->data, propval, target->data,
                                   opt_state->recursive, pool));
 
-      if (! opt_state->quiet)
+      if (! opt_state->quiet) {
+        svn_stringbuf_t *propname_native, *target_native;
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (propname, &propname_native,
+                                              pool));
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (target, &target_native, pool));
         printf ("property `%s' set%s on '%s'\n",
-                propname->data,
+                propname_native->data,
                 opt_state->recursive ? " (recursively)" : "",
-                target->data);
+                target_native->data);
+      }
     }
 
   return SVN_NO_ERROR;
Index: ./subversion/clients/cmdline/proplist-cmd.c
===================================================================
--- ./subversion/clients/cmdline/proplist-cmd.c
+++ ./subversion/clients/cmdline/proplist-cmd.c	Wed May 22 19:00:14 2002
@@ -28,6 +28,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -59,11 +60,14 @@
         {
           svn_client_proplist_item_t *item 
               = ((svn_client_proplist_item_t **)props->elts)[j];
-          printf("Properties on '%s':\n", item->node_name->data);
+          svn_stringbuf_t *node_name_native;
+          SVN_ERR (svn_utf_stringbuf_from_utf8 (item->node_name,
+                                                &node_name_native, pool));
+          printf("Properties on '%s':\n", node_name_native->data);
           if (opt_state->verbose)
-            svn_cl__print_prop_hash (item->prop_hash, pool);
+            SVN_ERR (svn_cl__print_prop_hash (item->prop_hash, pool));
           else
-            svn_cl__print_prop_names (item->prop_hash, pool);
+            SVN_ERR (svn_cl__print_prop_names (item->prop_hash, pool));
         }
     }
 
Index: ./subversion/clients/cmdline/trace-update.c
===================================================================
--- ./subversion/clients/cmdline/trace-update.c
+++ ./subversion/clients/cmdline/trace-update.c	Wed May 22 16:20:39 2002
@@ -26,13 +26,14 @@
 #include "svn_pools.h"
 #include "svn_path.h"
 #include "svn_string.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
 
 struct edit_baton
 {
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* UTF-8! */
   apr_pool_t *pool;
   svn_revnum_t target_revision;
   svn_boolean_t is_checkout;
@@ -45,7 +46,7 @@
 {
   struct edit_baton *edit_baton;
   struct dir_baton *parent_dir_baton;
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* UTF-8! */
   svn_boolean_t prop_changed;
 };
 
@@ -54,7 +55,7 @@
 {
   struct edit_baton *edit_baton;
   struct dir_baton *parent_dir_baton;
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* UTF-8! */
   svn_boolean_t added;
   svn_boolean_t text_changed;
   svn_boolean_t prop_changed;
@@ -143,7 +144,11 @@
   struct dir_baton *pb = parent_baton;
   struct edit_baton *eb = pb->edit_baton;
   eb->received_some_change = TRUE;
-  printf ("D  %s\n", svn_path_join (eb->path->data, path, pool));
+  svn_stringbuf_t *path_native;
+  SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (svn_path_join (eb->path->data,
+                                                               path, pool),
+                                                &path_native, pool));
+  printf ("D  %s\n", path_native->data);
   return SVN_NO_ERROR;
 }
 
@@ -159,9 +164,11 @@
   struct dir_baton *pb = parent_baton;
   struct edit_baton *eb = pb->edit_baton;
   struct dir_baton *new_db = make_dir_baton (path, eb, pb, pool);
+  svn_stringbuf_t *path_native;
 
   eb->received_some_change = TRUE;
-  printf ("A  %s\n", new_db->path->data);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (new_db->path, &path_native, pool));
+  printf ("A  %s\n", path_native->data);
   *child_baton = new_db;
   return SVN_NO_ERROR;
 }
@@ -192,6 +199,7 @@
   struct dir_baton *db = dir_baton;
   struct edit_baton *eb = db->edit_baton;
   char statchar_buf[3] = "_ ";
+  svn_stringbuf_t *path_native;
 
   if (db->prop_changed)
     {
@@ -212,7 +220,8 @@
       else
         statchar_buf[1] = 'U';
 
-      printf ("%s %s\n", statchar_buf, db->path->data);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (db->path, &path_native, subpool));
+      printf ("%s %s\n", statchar_buf, path_native->data);
 
       /* Destroy the subpool. */
       svn_pool_destroy (subpool);
@@ -228,6 +237,7 @@
   struct file_baton *fb = file_baton;
   struct edit_baton *eb = fb->edit_baton;
   char statchar_buf[3] = "_ ";
+  svn_stringbuf_t *path_native;
 
   if (fb->added)
     statchar_buf[0] = 'A';
@@ -277,7 +287,8 @@
     svn_pool_destroy (subpool);
   }
 
-  printf ("%s %s\n", statchar_buf, fb->path->data);
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (fb->path, &path_native, eb->pool));
+  printf ("%s %s\n", statchar_buf, path_native->data);
 
   return SVN_NO_ERROR;
 }
@@ -391,7 +402,7 @@
 svn_error_t *
 svn_cl__get_trace_update_editor (const svn_delta_editor_t **editor,
                                  void **edit_baton,
-                                 svn_stringbuf_t *initial_path,
+                                 svn_stringbuf_t *initial_path /* UTF-8! */,
                                  svn_boolean_t is_checkout,
                                  svn_boolean_t suppress_final_line,
                                  apr_pool_t *pool)
Index: ./subversion/clients/cmdline/trace-commit.c
===================================================================
--- ./subversion/clients/cmdline/trace-commit.c
+++ ./subversion/clients/cmdline/trace-commit.c	Wed May 22 18:59:34 2002
@@ -31,6 +31,7 @@
 #include "svn_pools.h"
 #include "svn_path.h"
 #include "svn_string.h"
+#include "svn_utf.h"
 
 #include "cl.h"
 
@@ -85,7 +86,7 @@
 
 struct edit_baton
 {
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* UTF-8! */
   apr_pool_t *pool;
   svn_boolean_t started_sending_txdeltas;
 };
@@ -95,7 +96,7 @@
 {
   struct edit_baton *edit_baton;
   struct dir_baton *parent_dir_baton;
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* UTF-8! */
   svn_boolean_t prop_changed;
   apr_hash_t *entrymods;
   apr_pool_t *pool;
@@ -106,7 +107,7 @@
 {
   struct edit_baton *edit_baton;
   struct dir_baton *parent_dir_baton;
-  svn_stringbuf_t *path;
+  svn_stringbuf_t *path; /* UTF-8! */
 };
 
 
@@ -255,19 +256,22 @@
   struct dir_baton *pb = db->parent_dir_baton;
   apr_hash_index_t *hi;
   void *vp = NULL;
+  svn_stringbuf_t *path_native;
 
   /* See if there is an entry in the parent's hash for this
      directory. */
   if (pb)
     vp = apr_hash_get (pb->entrymods, db->path->data, db->path->len);
 
+  SVN_ERR (svn_utf_stringbuf_from_utf8 (db->path, &path_native, db->pool));
+
   /* If this item was added to its parent's hash, print such.  Else,
      if it has propchanges, print that.  Otherwise, it should have
      just been 'open'ed, and that's not interesting enough to print.  */
   if (vp == ITEM_ADDED)
-    printf ("Adding          %s\n", db->path->data);
+    printf ("Adding          %s\n", path_native->data);
   else if (db->prop_changed)
-    printf ("Sending         %s\n", db->path->data); 
+    printf ("Sending         %s\n", path_native->data); 
 
   /* Now remove this from the parent's hash. */
   if (vp)
@@ -282,9 +286,13 @@
       const char *pattern;
       const void *key;
       void *val;
+      svn_stringbuf_t *key_native;
       
       apr_hash_this (hi, &key, NULL, &val);
       
+      SVN_ERR (svn_utf_stringbuf_from_utf8_cstring (key, &key_native,
+                                                    db->pool));
+
       if (val == ITEM_REPLACED)
         pattern = "Replacing       %s\n";
       else if (val == ITEM_REPLACED_BINARY)
@@ -300,7 +308,7 @@
       else
         abort(); /* this should never happen */
       
-      printf (pattern, (const char *)key);
+      printf (pattern, (const char *)key_native->data);
     }
 
   return SVN_NO_ERROR;
@@ -441,7 +449,7 @@
 svn_error_t *
 svn_cl__get_trace_commit_editor (const svn_delta_editor_t **editor,
                                  void **edit_baton,
-                                 svn_stringbuf_t *initial_path,
+                                 svn_stringbuf_t *initial_path /* UTF-8! */,
                                  apr_pool_t *pool)
 {
   /* Allocate an edit baton to be stored in every directory baton. */
Index: ./subversion/clients/cmdline/main.c
===================================================================
--- ./subversion/clients/cmdline/main.c
+++ ./subversion/clients/cmdline/main.c	Wed May 22 21:34:36 2002
@@ -41,6 +41,7 @@
 #include "svn_error.h"
 #include "svn_io.h"
 #include "svn_time.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -844,6 +845,7 @@
     {
       const char *opt_arg;
       svn_boolean_t ret;
+      svn_stringbuf_t *utf8_opt_arg;
 
       /* Parse the next option. */
       apr_err = apr_getopt_long (os, svn_cl__options, &opt_id, &opt_arg);
@@ -877,12 +879,18 @@
         ret = svn_cl__parse_revision (&opt_state, opt_arg, pool);
         if (ret)
           {
-            svn_handle_error (svn_error_createf
-                              (SVN_ERR_CL_ARG_PARSING_ERROR,
-                               0, NULL, pool,
-                               "Syntax error in revision argument \"%s\"",
-                               opt_arg),
-                              stderr, FALSE);
+            err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &utf8_opt_arg,
+                                                     pool);
+
+            if (err)
+              svn_handle_error (err, stderr, FALSE);
+            else
+              svn_handle_error (svn_error_createf
+                                (SVN_ERR_CL_ARG_PARSING_ERROR,
+                                 0, NULL, pool,
+                                 "Syntax error in revision argument \"%s\"",
+                                 utf8_opt_arg->data),
+                                stderr, FALSE);
             svn_pool_destroy (pool);
             return EXIT_FAILURE;
           }
@@ -891,11 +899,17 @@
         ret = parse_date (&opt_state, opt_arg, pool);
         if (ret)
           {
-            svn_handle_error (svn_error_createf
-                              (SVN_ERR_CL_ARG_PARSING_ERROR,
-                               0, NULL, pool,
-                               "Unable to parse \"%s\"", opt_arg),
-                              stderr, FALSE);
+            err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &utf8_opt_arg,
+                                                     pool);
+
+            if (err)
+              svn_handle_error (err, stderr, FALSE);
+            else
+              svn_handle_error (svn_error_createf
+                                (SVN_ERR_CL_ARG_PARSING_ERROR,
+                                 0, NULL, pool,
+                                 "Unable to parse \"%s\"", utf8_opt_arg->data),
+                                stderr, FALSE);
             svn_pool_destroy (pool);
             return EXIT_FAILURE;
           }
@@ -917,13 +931,30 @@
         opt_state.quiet = TRUE;
         break;
       case svn_cl__xml_file_opt:
-        opt_state.xml_file = svn_stringbuf_create (opt_arg, pool);
+        err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &opt_state.xml_file,
+                                                 pool);
+        if (err)
+          {
+            svn_handle_error (err, stdout, FALSE);
+            svn_pool_destroy (pool);
+            return EXIT_FAILURE;
+          }
         break;
       case 'd':
-        opt_state.target = svn_stringbuf_create (opt_arg, pool);
+        err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &opt_state.target,
+                                                 pool);
+        if (err)
+          {
+            svn_handle_error (err, stdout, FALSE);
+            svn_pool_destroy (pool);
+            return EXIT_FAILURE;
+          }
         break;
       case 'F':
-        err = svn_string_from_file (&(opt_state.filedata), opt_arg, pool);
+        err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &utf8_opt_arg, pool);
+        if (!err)
+          err = svn_string_from_file (&(opt_state.filedata),
+                                      utf8_opt_arg->data, pool);
         if (err)
           {
             svn_handle_error (err, stdout, FALSE);
@@ -934,8 +965,7 @@
         {
           svn_wc_entry_t *e;
 
-          err = svn_wc_entry (&e, svn_stringbuf_create (opt_arg, pool),
-                              FALSE, pool);
+          err = svn_wc_entry (&e, utf8_opt_arg, FALSE, pool);
           if ((err == SVN_NO_ERROR) && e)
             log_under_version_control = TRUE;
         }
@@ -943,14 +973,18 @@
       case svn_cl__targets_opt:
 	{
 	  svn_stringbuf_t *buffer;
-	  err = svn_string_from_file (&buffer, opt_arg, pool);
+          err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &utf8_opt_arg,
+                                                   pool);
+          if (!err)
+            err = svn_string_from_file (&buffer, utf8_opt_arg->data, pool);
+          if (!err)
+            err = svn_cl__newlinelist_to_array(&opt_state.targets, buffer, pool);
 	  if (err)
 	    {
 	      svn_handle_error (err, stdout, FALSE);
 	      svn_pool_destroy (pool);
 	      return EXIT_FAILURE;
 	    }
-	  opt_state.targets = svn_cl__newlinelist_to_array(buffer, pool);
 	}
         break;
       case svn_cl__force_opt:
@@ -967,10 +1001,26 @@
         opt_state.help = TRUE;
         break;
       case svn_cl__auth_username_opt:
-        opt_state.auth_username = svn_stringbuf_create (opt_arg, pool);
+        err = svn_utf_cstring_to_utf8_stringbuf (opt_arg,
+                                                 &opt_state.auth_username,
+                                                 pool);
+        if (err)
+          {
+            svn_handle_error (err, stdout, FALSE);
+            svn_pool_destroy (pool);
+            return EXIT_FAILURE;
+          }
         break;
       case svn_cl__auth_password_opt:
-        opt_state.auth_password = svn_stringbuf_create (opt_arg, pool);
+        err = svn_utf_cstring_to_utf8_stringbuf (opt_arg,
+                                                 &opt_state.auth_password,
+                                                 pool);
+        if (err)
+          {
+            svn_handle_error (err, stdout, FALSE);
+            svn_pool_destroy (pool);
+            return EXIT_FAILURE;
+          }
         break;
       case svn_cl__locale_opt:
         /* The only locale name that ISO C defines is the "C" locale;
@@ -986,10 +1036,16 @@
         */
         if (NULL == setlocale (LC_ALL, opt_arg))
           {
-            err = svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR,
-                                     0, NULL, pool,
-                                     "The locale `%s' can not be set",
-                                     opt_arg);
+            err = svn_utf_cstring_to_utf8_stringbuf (opt_arg, &utf8_opt_arg,
+                                                     pool);
+
+            if (err)
+              svn_handle_error (err, stderr, FALSE);
+            else
+              err = svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR,
+                                       0, NULL, pool,
+                                       "The locale `%s' can not be set",
+                                       utf8_opt_arg->data);
             svn_handle_error (err, stderr, FALSE);
           }
         break;
Index: ./subversion/clients/cmdline/feedback.c
===================================================================
--- ./subversion/clients/cmdline/feedback.c
+++ ./subversion/clients/cmdline/feedback.c	Wed May 22 16:47:59 2002
@@ -29,6 +29,7 @@
 #include <apr_want.h>
 
 #include "svn_pools.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -40,21 +41,16 @@
 
 
 static void 
-notify_added (void *baton, const char *path)
+notify_added (const char *path, const char *path_utf8,
+              svn_stringbuf_t *spath /* UTF-8! */, apr_pool_t *pool)
 {
-  struct notify_baton *nb = (struct notify_baton *) baton;
-
-  /* the pool (BATON) is typically the global pool; don't keep filling it */
-  apr_pool_t *subpool = svn_pool_create (nb->pool);
-
-  svn_stringbuf_t *spath = svn_stringbuf_create (path, subpool);
   svn_wc_entry_t *entry;
   svn_error_t *err;
   const char *type = "      ";  /* fill with "binary" if binary, etc */
 
   /* ### this sucks. we have to open/parse the entries file to get this
      ### information. when adding thousands of files, this blows... */
-  err = svn_wc_entry (&entry, spath, FALSE, subpool);
+  err = svn_wc_entry (&entry, spath, FALSE, pool);
   if (err)
     {
       printf ("WARNING: error fetching entry for %s\n", path);
@@ -71,7 +67,7 @@
       const svn_string_t *value;
 
       /* ### and again: open/parse a properties file. urk... */
-      err = svn_wc_prop_get (&value, SVN_PROP_MIME_TYPE, path, subpool);
+      err = svn_wc_prop_get (&value, SVN_PROP_MIME_TYPE, path_utf8, pool);
       if (err)
         {
           printf ("WARNING: error fetching %s property for %s\n",
@@ -88,7 +84,7 @@
   printf ("A  %s  %s\n", type, path);
 
  done:
-  svn_pool_destroy (subpool);
+  ;
 }
 
 
@@ -114,55 +110,74 @@
                      svn_wc_notify_action_t action, 
                      const char *path)
 {
+  struct notify_baton *nb = (struct notify_baton *) baton;
+
+  /* the pool (BATON) is typically the global pool; don't keep filling it */
+  apr_pool_t *subpool = svn_pool_create (nb->pool);
+
+  svn_stringbuf_t *spath = svn_stringbuf_create (path, subpool);
+  svn_stringbuf_t *spath_native;
+  svn_error_t *err;
+
+  err = svn_utf_stringbuf_from_utf8 (spath, &spath_native, subpool);
+  if (err)
+    {
+      printf ("WARNING: error decoding UTF-8 for ?\n");
+      goto done;
+    }
+
   switch (action)
     {
     case svn_wc_notify_add:
-      notify_added (baton, path);
-      return;
+      notify_added (spath_native->data, path, spath, subpool);
+      break;
 
     case svn_wc_notify_delete:
-      printf ("D  %s\n", path);
-      return;
+      printf ("D  %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_restore:
-      printf ("Restored %s\n", path);
-      return;
+      printf ("Restored %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_revert:
-      printf ("Reverted %s\n", path);
-      return;
+      printf ("Reverted %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_resolve:
-      printf ("Resolved conflicted state of %s\n", path);
-      return;
+      printf ("Resolved conflicted state of %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_update:
-      printf ("U   %s\n", path);
-      return;
+      printf ("U   %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_commit_modified:
-      printf ("Sending   %s\n", path);
-      return;
+      printf ("Sending   %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_commit_added:
-      printf ("Adding    %s\n", path);
-      return;
+      printf ("Adding    %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_commit_deleted:
-      printf ("Deleting  %s\n", path);
-      return;
+      printf ("Deleting  %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_commit_replaced:
-      printf ("Replacing %s\n", path);
-      return;
+      printf ("Replacing %s\n", spath_native->data);
+      break;
 
     case svn_wc_notify_commit_postfix_txdelta:
-      notify_commit_postfix_txdelta (baton, path);
-      return;
+      notify_commit_postfix_txdelta (baton, spath_native->data);
+      break;
 
     default:
       break;
     }
+
+ done:
+  svn_pool_destroy (subpool);
 }
 
 
Index: ./subversion/clients/cmdline/propedit-cmd.c
===================================================================
--- ./subversion/clients/cmdline/propedit-cmd.c
+++ ./subversion/clients/cmdline/propedit-cmd.c	Wed May 22 18:30:32 2002
@@ -28,6 +28,7 @@
 #include "svn_path.h"
 #include "svn_delta.h"
 #include "svn_error.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -62,6 +63,7 @@
       svn_string_t *propval;
       svn_stringbuf_t *new_propval;
       svn_stringbuf_t *base_dir = target;
+      svn_stringbuf_t *propname_native, *target_native;
       svn_wc_entry_t *entry;
 
       /* Fetch the current property. */
@@ -90,6 +92,9 @@
                                         propval,
                                         pool));
 
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (propname, &propname_native, pool));
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (target, &target_native, pool));
+
       /* ...and re-set the property's value accordingly. */
       if (new_propval)
         {
@@ -101,14 +106,14 @@
                                        FALSE,
                                        pool));
           printf ("Set new value for property `%s' on `%s'\n",
-                  propname->data,
-                  target->data);
+                  propname_native->data,
+                  target_native->data);
         }
       else
         {
           printf ("No changes to property `%s' on `%s'\n",
-                  propname->data,
-                  target->data);
+                  propname_native->data,
+                  target_native->data);
         }
     }
 
Index: ./subversion/clients/cmdline/info-cmd.c
===================================================================
--- ./subversion/clients/cmdline/info-cmd.c
+++ ./subversion/clients/cmdline/info-cmd.c	Wed May 22 17:17:00 2002
@@ -26,6 +26,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_path.h"
+#include "svn_utf.h"
 #include "cl.h"
 
 
@@ -64,10 +65,12 @@
   for (i = 0; i < targets->nelts; i++)
     {
       svn_stringbuf_t *target = ((svn_stringbuf_t **) (targets->elts))[i];
+      svn_stringbuf_t *native;
       svn_wc_entry_t *entry;
       svn_boolean_t text_conflict = FALSE, props_conflict = FALSE;
 
-      printf ("Path: %s\n", target->data);
+      SVN_ERR (svn_utf_stringbuf_from_utf8 (target, &native, pool));
+      printf ("Path: %s\n", native->data);
 
       SVN_ERR (svn_wc_entry (&entry, target, FALSE, pool));
       if (! entry)
@@ -82,14 +85,20 @@
          aren't in the entries file. */
 
       if ((entry->name) 
-          && strcmp (entry->name->data, SVN_WC_ENTRY_THIS_DIR))
-        printf ("Name: %s\n", entry->name->data);
+          && strcmp (entry->name->data, SVN_WC_ENTRY_THIS_DIR)) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->name, &native, pool));
+        printf ("Name: %s\n", native->data);
+      }
       
-      if (entry->url)
-        printf ("Url: %s\n", entry->url->data);
-          
-      if (entry->repos)
-        printf ("Repository: %s\n", entry->repos->data);
+      if (entry->url) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->url, &native, pool));
+        printf ("Url: %s\n", native->data);
+      }
+          
+      if (entry->repos) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->repos, &native, pool));
+        printf ("Repository: %s\n", native->data);
+      }
 
       if (SVN_IS_VALID_REVNUM (entry->revision))
         printf ("Revision: %" SVN_REVNUM_T_FMT "\n", entry->revision);
@@ -146,16 +155,22 @@
 
       if (entry->copied)
         {
-          if (entry->copyfrom_url)
-            printf ("Copied From Url: %s\n", entry->copyfrom_url->data);
+          if (entry->copyfrom_url) {
+            SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->copyfrom_url,
+                                                  &native, pool));
+            printf ("Copied From Url: %s\n", native->data);
+          }
 
           if (SVN_IS_VALID_REVNUM (entry->copyfrom_rev))
             printf ("Copied From Rev: %" SVN_REVNUM_T_FMT "\n",
                     entry->copyfrom_rev);
         }
 
-      if (entry->cmt_author)
-        printf ("Last Changed Author: %s\n", entry->cmt_author->data);
+      if (entry->cmt_author) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->cmt_author,
+                                              &native, pool));
+        printf ("Last Changed Author: %s\n", native->data);
+      }
 
       if (SVN_IS_VALID_REVNUM (entry->cmt_rev))
         printf ("Last Changed Rev: %" SVN_REVNUM_T_FMT "\n", entry->cmt_rev);
@@ -169,21 +184,34 @@
       if (entry->prop_time)
         svn_cl__info_print_time (entry->prop_time, "Properties Last Updated");
 
-      if (entry->checksum)
-        printf ("Checksum: %s\n", entry->checksum->data);
-
-      if (text_conflict && entry->conflict_old)
-        printf ("Conflict Previous Base File: %s\n", entry->conflict_old->data);
-
-      if (text_conflict && entry->conflict_wrk)
+      if (entry->checksum) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->checksum, &native, pool));
+        printf ("Checksum: %s\n", native->data);
+      }
+
+      if (text_conflict && entry->conflict_old) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->conflict_old,
+                                              &native, pool));
+        printf ("Conflict Previous Base File: %s\n", native->data);
+      }
+
+      if (text_conflict && entry->conflict_wrk) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->conflict_wrk,
+                                              &native, pool));
         printf ("Conflict Previous Working File: %s\n",
-                entry->conflict_wrk->data);
-
-      if (text_conflict && entry->conflict_new)
-        printf ("Conflict Current Base File: %s\n", entry->conflict_new->data);
+                native->data);
+      }
 
-      if (props_conflict && entry->prejfile)
-        printf ("Conflict Properties File: %s\n", entry->prejfile->data);
+      if (text_conflict && entry->conflict_new) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->conflict_new,
+                                              &native, pool));
+        printf ("Conflict Current Base File: %s\n", native->data);
+      }
+
+      if (props_conflict && entry->prejfile) {
+        SVN_ERR (svn_utf_stringbuf_from_utf8 (entry->prejfile, &native, pool));
+        printf ("Conflict Properties File: %s\n", native->data);
+      }
 
       /* Print extra newline separator. */
       printf ("\n");
Index: ./subversion/libsvn_subr/utf.c
===================================================================
--- /dev/null	Wed May 22 23:33:52 2002
+++ ./subversion/libsvn_subr/utf.c	Wed May 22 20:41:46 2002
@@ -0,0 +1,286 @@
+/*
+ * utf.c:  UTF-8 helper code shared among the Subversion libraries.
+ *
+ * ====================================================================
+ * Copyright (c) 2000-2002 CollabNet.  All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals.  For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ */
+
+
+
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <iconv.h>
+
+#include <apr_strings.h>
+
+#include "svn_string.h"
+#include "svn_error.h"
+#include "svn_pools.h"
+#include "svn_utf.h"
+
+
+#ifdef SVN_UTF8
+
+/* Figure out what the name of the native character set is, so
+   that we can pass it to iconv_open.                          */
+static const char *
+find_native_charset (void)
+{
+  /* First try $LC_CTYPE */
+  const char *dot, *ctype = getenv ("LC_CTYPE");
+
+  /* Skip anything before the dot, if any */
+  if (ctype != NULL && (dot = strchr (ctype, '.')))
+    ctype = dot + 1;
+
+  if (ctype != NULL && !strcmp (ctype, "iso_8859_1"))
+    ctype = "ISO8859-1";
+
+  if (ctype == NULL || ! *ctype) {
+    /* Fall back to US-ASCII */
+    ctype = "646";
+  }
+
+  return ctype;
+}
+
+/* Return the iconv handle for converting native characters to UTF-8.
+   Create one if it doesn't exist.                                    */
+static iconv_t
+get_ntou_iconv_handle (void)
+{
+  static iconv_t cd = (iconv_t)-1;
+
+  /* If we already have a handle, just return it. */
+  if (cd != (iconv_t)-1)
+    return cd;
+
+  /* Try to create one.  Also save it for later. */
+  return cd = iconv_open("UTF-8", find_native_charset());
+}
+
+/* Return the iconv handle for converting UTF-8 to native characters.
+   Create one if it doesn't exist.                                    */
+static iconv_t
+get_uton_iconv_handle (void)
+{
+  static iconv_t cd = (iconv_t)-1;
+
+  /* If we already have a handle, just return it. */
+  if (cd != (iconv_t)-1)
+    return cd;
+
+  /* Try to create one.  Also save it for later. */
+  return cd = iconv_open(find_native_charset(), "UTF-8");
+}
+
+
+static svn_error_t *
+svn_utf_convert_to_stringbuf (iconv_t cd,
+			      const char *src_data, apr_size_t src_length,
+			      svn_stringbuf_t **dest,
+			      apr_pool_t *pool)
+{
+  /* 2 bytes per character will be enough in most cases.
+     If not, we'll make a larger buffer and try again.   */
+  apr_size_t buflen = src_length * 2 + 1;
+
+  if (cd == (iconv_t)-1)
+    return svn_error_create (0, errno, NULL, pool, "recoding string");
+
+  do {
+
+    char *destbuf = apr_palloc (pool, buflen);
+
+    /* Set up state variables for iconv */
+    const char *srcptr = src_data;
+    char *destptr = destbuf;
+    size_t srclen = src_length;
+    size_t destlen = buflen;
+
+    /* Attempt the conversion */
+    if (iconv(cd, &srcptr, &srclen, &destptr, &destlen) != (size_t)-1) {
+
+      /* Conversion succeeded.  Return buffer */
+      *dest = svn_stringbuf_ncreate (destbuf, buflen - destlen, pool);
+
+      return SVN_NO_ERROR;
+    }
+
+    /* In case we got here because the buffer was too small,
+       double the size for the next iteration...              */
+    buflen *= 2;
+
+  } while (errno == E2BIG);
+
+  /* Some other error occured. */
+  return svn_error_create (0, errno, NULL, pool, "recoding string");
+}
+
+
+svn_error_t *
+svn_utf_stringbuf_to_utf8 (const svn_stringbuf_t *src,
+                           svn_stringbuf_t **dest,
+                           apr_pool_t *pool)
+{
+  /* Get a converter from the native character encoding to UTF-8 */
+  iconv_t cd = get_ntou_iconv_handle ();
+
+  return svn_utf_convert_to_stringbuf (cd, src->data, src->len, dest, pool);
+}
+
+svn_error_t *
+svn_utf_cstring_to_utf8_stringbuf (const char *src,
+                                   svn_stringbuf_t **dest,
+                                   apr_pool_t *pool)
+{
+  /* Get a converter from the native character encoding to UTF-8 */
+  iconv_t cd = get_ntou_iconv_handle ();
+
+  return svn_utf_convert_to_stringbuf (cd, src, strlen (src), dest, pool);
+}
+
+svn_error_t *
+svn_utf_stringbuf_from_utf8 (const svn_stringbuf_t *src,
+			     svn_stringbuf_t **dest,
+			     apr_pool_t *pool)
+{
+  /* Get a converter from UTF-8 to the native character encoding */
+  iconv_t cd = get_uton_iconv_handle ();
+
+  return svn_utf_convert_to_stringbuf (cd, src->data, src->len, dest, pool);
+}
+
+svn_error_t *
+svn_utf_stringbuf_from_utf8_string (const svn_string_t *src,
+				     svn_stringbuf_t **dest,
+				     apr_pool_t *pool)
+{
+  /* Get a converter from UTF-8 to the native character encoding */
+  iconv_t cd = get_uton_iconv_handle ();
+
+  return svn_utf_convert_to_stringbuf (cd, src->data, src->len, dest, pool);
+}
+
+svn_error_t *
+svn_utf_stringbuf_from_utf8_cstring (const char *src,
+				     svn_stringbuf_t **dest,
+				     apr_pool_t *pool)
+{
+  /* Get a converter from UTF-8 to the native character encoding */
+  iconv_t cd = get_uton_iconv_handle ();
+
+  return svn_utf_convert_to_stringbuf (cd, src, strlen (src), dest, pool);
+}
+
+
+char *
+svn_utf_utf8_to_native (const char *utf8_string,
+			char *buf, apr_size_t bufsize)
+{
+  /* Set up state variables for iconv */
+  const char *srcptr = utf8_string;
+  char *destptr = buf;
+  size_t srclen = strlen (utf8_string);
+  size_t destlen = bufsize-1;
+
+  /* Get a converter from UTF-8 to the native character encoding */
+  iconv_t cd = get_uton_iconv_handle ();
+
+  if (cd == (iconv_t)-1)
+    return NULL;
+
+  /* Attempt the conversion */
+  if (iconv(cd, &srcptr, &srclen, &destptr, &destlen) != (size_t)-1) {
+    /* Conversion succeeded.  Zero-terminate and return buffer */
+    *destptr = '\0';
+    return buf;
+  }
+
+  return NULL;
+}
+
+#else
+
+static svn_error_t *
+check_non_ascii (const char *data, apr_size_t len, apr_pool_t *pool)
+{
+  for (; len > 0; --len, data++)
+    if (*(unsigned char *)data >= 128 ||
+        *(unsigned char *)data == 27 /* Detect ISO-2022 etc */)
+      return svn_error_create (0, 0, NULL, pool,
+                               "non-ascii characters detected, "
+                               "please compile with --enable-utf8");
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_utf_stringbuf_to_utf8 (svn_stringbuf_t *src,
+                           svn_stringbuf_t **dest,
+                           apr_pool_t *pool)
+{
+  SVN_ERR (check_non_ascii (src->data, src->len, pool));
+  *dest = src;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_utf_stringbuf_from_utf8 (svn_stringbuf_t *src,
+			     svn_stringbuf_t **dest,
+			     apr_pool_t *pool)
+{
+  SVN_ERR (check_non_ascii (src->data, src->len, pool));
+  *dest = src;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_utf_stringbuf_from_utf8_cstring (const char *src,
+				     svn_stringbuf_t **dest,
+				     apr_pool_t *pool)
+{
+  SVN_ERR (check_non_ascii (src, strlen (src), pool));
+  *dest = svn_stringbuf_create (src, pool);
+  return SVN_NO_ERROR;
+}
+
+char *
+svn_utf_utf8_to_native (const char *utf8_string,
+			char *buf, apr_size_t bufsize)
+{
+  int i;
+
+  /* Just replace non-ASCII characters with '?' here... */
+
+  for (i=0; i<bufsize && *utf8_string; utf8_string++)
+    if (*(unsigned char *)utf8_string < 128)
+      /* ASCII character */
+      buf[i++] = *utf8_string;
+    else if(*(unsigned char *)utf8_string >= 192)
+      /* First octet of a multibyte sequence */
+      buf[i++] = '?';
+
+  buf[i>=bufsize? bufsize-1 : i] = '\0';
+  return buf;  
+}
+
+#endif /* SVN_UTF8 */
+
+
+/* 
+ * local variables:
+ * eval: (load-file "../../tools/dev/svn-dev.el")
+ * end:
+ */
Index: ./subversion/include/svn_utf.h
===================================================================
--- /dev/null	Wed May 22 23:33:52 2002
+++ ./subversion/include/svn_utf.h	Sun May 19 00:39:10 2002
@@ -0,0 +1,74 @@
+/*  svn_utf.h:  UTF-8 code shared by various Subversion libraries.
+ *
+ * ====================================================================
+ * Copyright (c) 2000-2002 CollabNet.  All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals.  For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ */
+
+
+
+#ifndef SVN_UTF_H
+#define SVN_UTF_H
+
+#include "svn_error.h"
+#include "svn_delta.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/*** UTF-8 conversions ***/
+
+/* Convert a stringbuf from native character encoding to UTF-8 */
+svn_error_t *svn_utf_stringbuf_to_utf8 (const svn_stringbuf_t *src,
+                                        svn_stringbuf_t **dest,
+                                        apr_pool_t *pool);
+
+/* Convert a C string from native character encoding to an UTF-8 stringbuf */
+svn_error_t *svn_utf_cstring_to_utf8_stringbuf (const char *src,
+                                        svn_stringbuf_t **dest,
+                                        apr_pool_t *pool);
+
+/* Convert a stringbuf from UTF-8 to native character encoding */
+svn_error_t *svn_utf_stringbuf_from_utf8 (const svn_stringbuf_t *src,
+					  svn_stringbuf_t **dest,
+					  apr_pool_t *pool);
+
+/* Convert an UTF-8 string to a stringbuf with native character encoding */
+svn_error_t *svn_utf_stringbuf_from_utf8_string (const svn_string_t *src,
+                                                 svn_stringbuf_t **dest,
+                                                 apr_pool_t *pool);
+
+/* Convert an UTF-8 C string to a stringbuf with native character encoding */
+svn_error_t *svn_utf_stringbuf_from_utf8_cstring (const char *src,
+						  svn_stringbuf_t **dest,
+						  apr_pool_t *pool);
+
+/* Convert a C string from UTF-8 to native character encoding */
+/* This function is for error message printing only... */
+char *svn_utf_utf8_to_native (const char *utf8_string,
+			      char *buf, apr_size_t bufsize);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* SVN_XML_H */
+
+/* ----------------------------------------------------------------
+ * local variables:
+ * eval: (load-file "../../tools/dev/svn-dev.el")
+ * end: 
+ */


