Reputation: 45
I am trying to download image using an url like:
url --> http://www.example.com/path/to/image-ğüçöşı.jpg
InputStream input = new java.net.URL(url).openStream();
Bitmap bitmap = BitmapFactory.decodeStream(input);
However in the first line app crashes. Because it has a character like "ı" or "ç". If url doesn't has those character it doesn't crash and works fine. I could almost say i tried most of the solutions like utf8 encoding and etc, including giving "UTF8" params to HttpClient.
It would be appreciated very much if you could help me. I am looking for any solution that doesn't slow down the code very much.
Thank you
Upvotes: 0
Views: 654
Reputation: 3029
Encode your url or only image name with this code
String query = URLEncoder.encode("strangeChars", "utf-8");
Upvotes: 2