Judging from all the sample code ignoring the recommendation, I'd say not many people did know. That is why I posted the quote from the API docs.
OTOH, it is a mild nuisance that URI throws URISyntaxException, which isn't even an IOException. So I suspect the desire to avoid dealing with this is the reason so much sample code ignores the recommendation. But professional quality code should not avoid this. It should follow the recommendation and deal properly with the exception. On Feb 14, 4:23 pm, Kevin Duffey <[email protected]> wrote: > Good info Indicator.. I did not read both APIs to know that either was > better than the other... for URIs this is good to know. > > On Sun, Feb 14, 2010 at 3:44 PM, Indicator Veritatis <[email protected]>wrote: > > > > > RFC2396 does list '^' as one of the 'unwise' characters. The inference > > is that '^' should be escaped, though the RFC does not say so > > explicitly. > > > The Java API docs on URI and URLencode, OTOH, recommend always using > > URI rather than URLEncode, converting from URI to URL only as needed, > > using toURL. > > > The API refs exact words: > > > Note, the URI class does perform escaping of its component fields in > > certain circumstances. The recommended way to manage the encoding and > > decoding of URLs is to use URI, and to convert between these two > > classes using toURI() and URI.toURL(). > > > The URLEncoder and URLDecoder classes can also be used, but only for > > HTML form encoding, which is not the same as the encoding scheme > > defined in RFC2396. > > > On Feb 13, 11:55 pm, ivanchan <[email protected]> wrote: > > > Hi all, > > > > I am trying to use HttpGet to fetch some data from yahoo finace, the > > > whole url is > > > "http://finance.yahoo.com/q/hp?s=^DJI", from the log I gucess it > > > complains > > > about the '^' character, what is the right way to solve this problem? > > > Thanks. > > > > E/AndroidRuntime( 287): java.lang.IllegalArgumentException: Illegal > > > character i > > > n query at index 32:http://finance.yahoo.com/q/hp?s=^DJI > > > E/AndroidRuntime( 287): at java.net.URI.create(URI.java:970) > > > E/AndroidRuntime( 287): at > > > org.apache.http.client.methods.HttpGet.<init> > > > (HttpGet.java:75) > > > E/AndroidRuntime( 287): at > > > Ivan.stock.droid.HttpHelper.connect(HttpHelpe > > > > Regards, > > > Ivan > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Beginners" group. > > > NEW! Try asking and tagging your question on Stack Overflow at > >http://stackoverflow.com/questions/tagged/android > > > To unsubscribe from this group, send email to > > [email protected]<android-beginners%2Bunsubscr > > [email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

