users@jersey.java.net

Re: [Jersey] .toASCIIString instead of .toString

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Tue, 17 Jun 2008 12:15:26 +0200

On Tue, Jun 17, 2008 at 11:54:40AM +0200, Paul Sandoz wrote:
> Hi Max,
>
> Nice catch, we should fix those. A bit of context to remind ourselves:
> these are associated with the Bookmark example.

fixed in Bookmarks and Users resources; i will probably also
convert the client to use Jersey client API before the 0.8 release...

~Jakub

>
> Paul.
>
> Max Scheffler wrote:
> >Hi there,
> >
> >I found some code snippets in the jersey examples which look like the
> >following:
> >
> > URI userUri = ub.
> > path(userEntity.getUserid()).
> > build();
> > uriArray.put(userUri.toString());
> >
> >which means nothing else than using the .toString method from the URI
> >class.
> >
> >I found the .toASCIIString() method of URI. The JavaDoc of this method
> >tells us:
> >
> > Returns the content of this URI as a US-ASCII string.
> >
> > If this URI does not contain any characters in the other category then
> > an invocation of this method will return the same value as an
> > invocation of the toString method. Otherwise this method works as if
> > by invoking that method and then encoding the result.
> >
> > @return The string form of this URI, encoded as needed
> > so that it only contains characters in the US-ASCII
> > charset
> >
> >IMHO is the .toASCIIString() method the more right one to generate a
> >String from a URI.
> >
> >To prove that I'm right i wrote this little test:
> >
> > public static void main ( String[] args ) throws URISyntaxException {
> > URI uri = new URI( "http://www.example.org/äö" );
> > System.out.println( uri.toString() );
> > System.out.println( uri.toASCIIString() );
> > }
> >
> >Which returns the following to me:
> >
> > http://www.example.org/?
> > http://www.example.org/%C3%A4%C3%B6
> >
> >Greetings
> > Max
>
> --
> | ? + ? = To question
> ----------------\
> Paul Sandoz
> x38109
> +33-4-76188109
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
http://blogs.sun.com/japod