Index: subversion/include/svn_path.h
===================================================================
--- subversion/include/svn_path.h	(Revision 20635)
+++ subversion/include/svn_path.h	(Arbeitskopie)
@@ -389,6 +389,22 @@
  */
 svn_error_t *svn_path_check_valid(const char *path, apr_pool_t *pool);
 
+/**
+ * If svn_path_check_valid() gave an error, these two functions may be 
+ * used to encode/decode the path to a string which may be stored in
+ * the repository.
+ *
+ * Per definition the property @c SVN_PROP_FN_ENCODED should be set
+ * to the value @c SVN_PROP_FN_ENCODED_VALUE to indicate that this path
+ * must not be used directly.
+ *
+ * The encoded format is like "tab\\x09name". 
+ * Please note that a string which does not strictly parse according
+ * to this format will be rejected. */
+svn_error_t *svn_path_encode(const char *path, char **output, apr_pool_t *pool);
+
+svn_error_t *svn_path_decode(const char *path, char **output, apr_pool_t *pool);
+
 
 /** URI/URL stuff
  *
Index: subversion/include/svn_props.h
===================================================================
--- subversion/include/svn_props.h	(Revision 20635)
+++ subversion/include/svn_props.h	(Arbeitskopie)
@@ -200,6 +200,14 @@
 /** The value to force the executable property to when set */
 #define SVN_PROP_EXECUTABLE_VALUE "*"
 
+/** If set, indicates that the filename must be en/decoded before use.
+ * See svn_path_encode() and svn_path_decode(). */
+#define SVN_PROP_FN_ENCODED SVN_PROP_PREFIX "filename-encoded"
+
+/** The value for SVN_PROP_FN_ENCODED, to indicate that
+ *  the filename must be de-coded before use */
+#define SVN_PROP_FN_ENCODED_VALUE "*"
+
 /** Set to TRUE ('*') if we want a file to be set to read-only when
  * not locked.  FALSE is indicated by deleting the property. */
 #define SVN_PROP_NEEDS_LOCK  SVN_PROP_PREFIX "needs-lock"
Index: subversion/libsvn_subr/path.c
===================================================================
--- subversion/libsvn_subr/path.c	(Revision 20635)
+++ subversion/libsvn_subr/path.c	(Arbeitskopie)
@@ -1258,3 +1258,83 @@
 
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_path_encode(const char *path, char **output, apr_pool_t *pool)
+{
+  const char *c;
+  char *dest, *cp;
+  int to_encode, len;
+
+  to_encode=len=0;
+  for (c = path; *c; c++)
+    {
+      len++;
+      if (svn_ctype_iscntrl(*c))
+        to_encode++;
+    }
+
+  if (to_encode == 0)
+    return svn_error_createf
+        (SVN_ERR_FS_PATH_SYNTAX, NULL,
+         _("Path '%s' needs not be encoded!"),
+         svn_path_local_style(path, pool));
+
+  /* For each character to encode we need 3 bytes: "\t" => "\\x09";
+   * plus termination. */
+  dest=apr_palloc(pool, len + 3*to_encode + 4);
+  for (c = path, cp = dest; *c; c++)
+    {
+      if (svn_ctype_iscntrl(*c))
+        {
+          cp += sprintf(cp, "\\x%x", *(unsigned char*)c);
+        }
+      else
+        *(cp++) = *(c++);
+    }
+
+  *output = dest;
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_path_decode(const char *path, char **output, apr_pool_t *pool)
+{
+  char *c, *dest, *target;
+  char buffer[3];
+  int decoded;
+
+  /* On decode the path can only get shorter. */
+  dest=apr_pstrdup(pool, path);
+  decoded=0;
+  buffer[2]=0;
+
+  c=target=dest; 
+  do
+    {
+      /* To avoid parsing the hexadecimal ourself we copy 
+       * the 2 digits into a buffer. */
+      if (c[0] == '\\' &&
+          c[1] == 'x' &&
+          apr_isxdigit( buffer[0]=c[2] ) && 
+          apr_isxdigit( buffer[1]=c[3] ) )
+        *target = apr_strtoi64(buffer, NULL, 16);
+      else
+        *target = *(c++);
+
+      target++;
+    } while (*c);
+
+  if (decoded == 0)
+    return svn_error_createf
+        (SVN_ERR_FS_PATH_SYNTAX, NULL,
+         _("Path '%s' needs not be decoded!"),
+         svn_path_local_style(path, pool));
+
+  *output = dest;
+
+  return SVN_NO_ERROR;
+}


