I want to create web application by square picasso, but if image url contains persian characters (ا،ب،ج،ی، ...) Picasso not load image.
This url not working:
Picasso.with(mContext).load("http://www.shutterstock.ir/thumbs/10006/74601661-گربه-چشم-ابی-ولاغر-سیامی-در-یک-پس-زمینه-،-وکتور-سفید.jpg")
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.face_top_image).noFade().resize(100, 100)
.into(imageView);
This url work
Picasso.with(mContext).load("http://www.shutterstock.ir/thumbs/10006/74601661-%DA%AF%D8%B1%D8%A8%D9%87-%DA%86%D8%B4%D9%85-%D8%A7%D8%A8%DB%8C-%D9%88%D9%84%D8%A7%D8%BA%D8%B1-%D8%B3%DB%8C%D8%A7%D9%85%DB%8C-%D8%AF%D8%B1-%DB%8C%DA%A9-%D9%BE%D8%B3-%D8%B2%D9%85%DB%8C%D9%86%D9%87-%D8%8C-%D9%88%DA%A9%D8%AA%D9%88%D8%B1-%D8%B3%D9%81%DB%8C%D8%AF.jpg")
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.face_top_image).noFade().resize(100, 100)
.into(imageView);
You need to URI encode the URL.
See the docs
Uri.encode(url);
Or, if specifying certain allowed characters the following works:
private static final String ALLOWED_URI_CHARS = "@#&=*+-_.,:!?()/~'%";
String urlEncoded = Uri.encode(path, ALLOWED_URI_CHARS);
You need to encode your Url
.
So try this
URIUtil.encodeQuery(myUrl).
or also this one : http://developer.android.com/reference/java/net/URLEncoder.html
URLEncoder.encode(myUrl, "UTF-8");
Also there is an issue here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With