java.net.URLEncoder

Put your problem here if it does not fit any of the other categories.

java.net.URLEncoder

Postby aetmos » Fri Jan 18, 2008 3:59 am

Hi All,

The documentation for java.net.URLEncoder specifies that encode(String s) is deprecated in favor of encode(String s, String enc). Problem is, enc isn't described in the parameters section. I've tried setting enc to "UTF-8", "US-ASCII", "ISO-8859-1", and "application/x-www-form-urlencoded", and nothing works, I keep getting the same UnsupportedEncodingException. Does anybody know what I'm supposed to use for this parameter?

http://code.google.com/android/referenc ... coder.html

Thanks,
Tom
aetmos
Junior Developer
Junior Developer
 
Posts: 21
Joined: Fri Jan 18, 2008 12:33 am

Top

Postby cabernet1976 » Fri Jan 18, 2008 5:27 am

Hi aetmos,

Could you paste your code here? I think it will be useful to clear your issue.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby aetmos » Fri Jan 18, 2008 5:34 am

Hi cabernet1976,

Well, what I'm actually trying to do is URLEncode my HTTP_Request vars, like so:

Code: Select all
//(import java.net.URLEncoder;)
...
vars.put(URLEncoder.encode(titleText.getText().toString(),"UTF-8"),URLEncoder.encode(bodyText.getText().toString(),"UTF-8"));


but the issue I'm having can be illustrated like this, too:

Code: Select all
//(import java.net.URLEncoder;)
...
URLEncoder.encode("blah blah blah","UTF-8");


Thanks,
Tom
aetmos
Junior Developer
Junior Developer
 
Posts: 21
Joined: Fri Jan 18, 2008 12:33 am

Postby aetmos » Fri Jan 18, 2008 9:53 pm

Never mind...I just wasn't catching the exception with try{}. Apparently the potential for an uncaught exception is enough to trigger a compiler error?
aetmos
Junior Developer
Junior Developer
 
Posts: 21
Joined: Fri Jan 18, 2008 12:33 am

Postby plusminus » Sat Jan 19, 2008 2:14 pm

Hello aetmos,

compiler beefs only on explicitly thrown Exceptions (which are nun RunTimeExceptions).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby aetmos » Sat Jan 19, 2008 5:13 pm

plusminus wrote:Hello aetmos,

compiler beefs only on explicitly thrown Exceptions (which are nun RunTimeExceptions).

Regards,
plusminus


Thanks, plusminus. It seems I have a lot to learn about Java ;-)
aetmos
Junior Developer
Junior Developer
 
Posts: 21
Joined: Fri Jan 18, 2008 12:33 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests