You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by MONTEUX Eric <er...@alyotech.fr> on 2007/01/29 10:12:13 UTC
File names encoding
I am currently developping a subversion client in C++.
I have a problem with blank characters existing in my file names.
The svn api says the url of such files is malformed.
How can I encode the file names in such a way that it is considered as a valid url ?
They must be encoded in UTF-8 from what I understood.
That is what I have done, using the utf8 encoder provided with QT.
However, this does not solve my problem.
Apparently, utf8 encoding does not transforrm blank characters into something else, so I must have missed something elsewhere...
I also watched inside the tortoiseSvn source code, but I can't use it since I need a portable (windows / linux) implementation.
Help would be appreciated.
Thanks in advance.
Best regards,
Eric.
Re: File names encoding
Posted by Daniel Rall <dl...@collab.net>.
On Sat, 03 Feb 2007, Martin Hauner wrote:
> Hi,
>
> Daniel Rall wrote:
> >>MONTEUX Eric wrote:
> >>>I am currently developping a subversion client in C++.
> >>>I have a problem with blank characters existing in my file names.
> >>>The svn api says the url of such files is malformed.
> >>>
> >[..]
> >
> >From svn_path.h:
> >
> >/** Return a URI-encoded copy of @a path, allocated in @a pool. */
> >const char *svn_path_uri_encode(const char *path, apr_pool_t *pool);
>
> I had a similar problem in subcommander and found that there is code
> hidden in svn_opt_args_to_target_array2 (which is duplicated in other
> svn tools) to prepare a string for an svn api call (path or url).
>
> I created a patch last november (thread "preparing a path or url for
> an svn api call....") which moved this code to a public api function.
> Unfortunately, the patch was never reviewed and ended up in the issue
> tracker as issue 2676.
+1, this looks like a good idea to me.
Re: File names encoding
Posted by Martin Hauner <ma...@gmx.net>.
Hi,
Daniel Rall wrote:
>> MONTEUX Eric wrote:
>>> I am currently developping a subversion client in C++.
>>> I have a problem with blank characters existing in my file names.
>>> The svn api says the url of such files is malformed.
>>>
>[..]
>
> From svn_path.h:
>
> /** Return a URI-encoded copy of @a path, allocated in @a pool. */
> const char *svn_path_uri_encode(const char *path, apr_pool_t *pool);
I had a similar problem in subcommander and found that there is code
hidden in svn_opt_args_to_target_array2 (which is duplicated in other
svn tools) to prepare a string for an svn api call (path or url).
I created a patch last november (thread "preparing a path or url for
an svn api call....") which moved this code to a public api function.
Unfortunately, the patch was never reviewed and ended up in the issue
tracker as issue 2676.
--
Martin
Subcommander 1.2.2 - http://subcommander.tigris.org
a cross platform Win32/Unix/MacOSX subversion GUI client & diff/merge tool.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: File names encoding
Posted by Daniel Rall <dl...@collab.net>.
On Tue, 30 Jan 2007, Michael Sinz wrote:
> MONTEUX Eric wrote:
> >
> >I am currently developping a subversion client in C++.
> >I have a problem with blank characters existing in my file names.
> >The svn api says the url of such files is malformed.
> >
> >How can I encode the file names in such a way that it is considered as a
> >valid url ?
>
> URL encoding has the file name escaped as per RFC2396. This is "%xx" where
> the xx is the hex code for the character. For example, "%20" would be a
> space and thus a file of "one space" would be "one%20space"
>
> All non-alpha-numeric characters or special path characters should be
> encoded.
> See http://www.ietf.org/rfc/rfc2396.txt
>
> [...]
>
> >I also watched inside the tortoiseSvn source code, but I can't use it
> >since I need a portable (windows / linux) implementation.
>
> I don't remember where the function is right now (I have been playing on
> the Java side a bit too much lately and know where to do it there) but
> a conversion from UTF8 path into URL encoding should be readily available.
>
> See http://www.w3.org/International/O-URL-code.html
From svn_path.h:
/** Return a URI-encoded copy of @a path, allocated in @a pool. */
const char *svn_path_uri_encode(const char *path, apr_pool_t *pool);
Re: File names encoding
Posted by Michael Sinz <Mi...@sinz.org>.
MONTEUX Eric wrote:
>
> I am currently developping a subversion client in C++.
> I have a problem with blank characters existing in my file names.
> The svn api says the url of such files is malformed.
>
> How can I encode the file names in such a way that it is considered as a
> valid url ?
URL encoding has the file name escaped as per RFC2396. This is "%xx" where
the xx is the hex code for the character. For example, "%20" would be a
space and thus a file of "one space" would be "one%20space"
All non-alpha-numeric characters or special path characters should be encoded.
See http://www.ietf.org/rfc/rfc2396.txt
[...]
> I also watched inside the tortoiseSvn source code, but I can't use it
> since I need a portable (windows / linux) implementation.
I don't remember where the function is right now (I have been playing on
the Java side a bit too much lately and know where to do it there) but
a conversion from UTF8 path into URL encoding should be readily available.
See http://www.w3.org/International/O-URL-code.html
--
Michael Sinz Technology and Engineering Director/Consultant
"Starting Startups" mailto:michael.sinz@sinz.org
My place on the web http://www.sinz.org/Michael.Sinz
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org