I have a URL string in the following format.
http://myserver.com/_layouts/feed.aspx?xsl=4&web=%2F&page=dda3fd10-c776-4d69-8c55-2f1c74b343e2&wp=476f174a-82df-4611-a3df-e13255d97533
I want to replace & with & in the above URL. My result should be:
http://myserver.com/_layouts/feed.aspx?xsl=4&web=%2F&page=dda3fd10-c776-4d69-8c55-2f1c74b343e2&wp=476f174a-82df-4611-a3df-e13255d97533
Can someone post me the code to get this done?
i changed the code like this. but not working
if (name.equalsIgnoreCase(LINK))
{
Log.v(TAG,"link link: "+property.getFirstChild().getNodeValue().replace("&","&"));
message.setLink(property.getFirstChild().getNodeValue().replace("&","&"));
}
Thanks
How about:
private String decode(String url)
{
return url.replace("&", "&");
}
Decode:
Html.fromHtml((String) htmlCode).toString();
Encode:
TextUtils.htmlEncode(url)
String.replace(target, replacement)
Related
This is the API I want to get: http://itunes.apple.com/us/rss/topsongs/limit=20/genre=29/explicit=true/json
How can I replace "29" by another number programmatically?
I have read many docs, but all of them have the same form with "?". Ex: https://api.example.com/tasks?id=123. I cannot apply their solution to my problem.
Thanks for your help.
Try this
#GET("users/{user}/repos")
Call<Response> listRepos(#Path("user") String user)
Try with
int your_number = 20;
String url = "http://itunes.apple.com/us/rss/topsongs/limit=20/genre=29/explicit=true/json;"
url = url.replace("genre=29", "genre"+your_number);
and now use url for requesting.
I want to pass an array as parameter like this:
images[] = "Base64String A..."
images[] = "Base64String B..."
images[] = "Base64String C..."
images[] = "Base64String ..."
I'm using Laravel 5.1 on server side.
My controller to handle post data:
public function uploadTempImage(){
if (Input::has('images')) {
$images = Input::get('images');
$barcode_id =Input::get('barcode_id');
$upload_count=0;
foreach($images as $string_image) {
$image = base64_decode($string_image);
$filename = "$barcode_id$upload_count".time().date("d").date("m").date("Y").".jpeg";
$upload_count +=Storage::disk('local')->put("/tempImage/".$filename , $image);
}
return $upload_count;
}else{
return 'no file uploaded';
}
}
i use postman to test my server and its working..
please help me get over this.. thanks
TL;DR using arrays in form data like this is a bit problematic and hardly standardized. Avoid if possible.
Long version
Read this issue on retrofit's github
If the strings won't be too massive, consider using JSON as your transport vehicle, and declare a JSON array to store your base64 strings.
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
just use from this function
public static String encodUrl(String url){
String[] splitUrl = url.split("/");
String imageName = splitUrl[splitUrl.length-1];//get name of file
String mainUrl = url.replaceAll(imageName , "");//get url without file name bacause dont need to encode
return (mainUrl + Uri.encode(imageName));
}
String strArr[]={"सांखà¥à¤¯à¤¯à¥‹à¤—",
"'करà¥à¤®à¤¯à¥‹à¤—",
"जà¥à¤žà¤¾à¤¨à¤•à¤°à¥à¤®à¤¸à¤‚नà¥à¤¯à¤¾à¤¸à¤¯à¥‹à¤—",
"करà¥à¤®à¤¸à¤‚नà¥à¤¯à¤¾à¤¸à¤¯à¥‹à¤—",
"आतà¥à¤®à¤¸à¤‚यमयोग",
"जà¥à¤žà¤¾à¤¨à¤µà¤¿à¤œà¥à¤žà¤¾à¤¨à¤¯à¥‹à¤—"};
I have UTF-8 code like this when I have converted into string am getting like:
सा�?�?्यय�?�?'�?र्मय�?�?�?्�?ान�?र्मस�?न्यासय�?�?�?र्मस�?न्यासय�?�?�?त्मस�?यमय�?�?
�?्�?ानवि�?्�?ानय�?�?सा�?�?्यय�?�?'�?र्मय�?�?�?्�?ान�?र्मस�?न्यासय�?�?�?र्मस�?
न्यासय�?�?�?त्मस�?यमय�?�?�?्�?ानवि�?्�?ानय�?�?सा�?�?्यय�?�?'�?र्मय�?�?�?्�?ान�?
र्मस�?न्यासय�?�?�?र्मस�?न्यासय�?�?�?त्मस�?यमय�?�?�?्�?ानवि�?्�?ानय�?�?सा�?�?्यय�?
�?'�?र्मय�?�?�?्�?ान�?र्मस�?न्यासय�?�?�?र्मस�?न्यासय�?�?�?त्मस�?यमय�?�?�?्�?ानवि�?्
�?ानय�?�?सा�?�?्यय�?�?'�?र्मय�?�?�?्�?ान�?र्मस�?न्यासय�?�?�?र्मस�?न्यासय�?�?�?
त्मस�?यमय�?�?�?्�?ानवि�?्�?ानय�?�?सा�?�?्यय�?�?'�?र्मय�?�?�?्�?ान�?र्मस�?न्यासय�?
�?�?र्मस�?न्यासय�?�?�?त्मस�?यमय�?�?�?्�?ानवि�?्�?ानय�?�?सा�?�?्यय�?�?'�?र्मय�?�?
�?्�?ान�?र्मस�?न्यासय�?�?�?र्मस�?न्यासय�?�?�?त्मस�?यमय�?�?�?्�?ानवि�?्�?ानय�?�?
please anyone help to get proper string value!
[EDIT]
Code:
public static String convertFromUTF8(String s) {
String out = null;
try {
out = new String(s.getBytes("ISO-8859-1"), "UTF-8");
} catch (java.io.UnsupportedEncodingException e) {
return null;
} return out;
}
assuming you are using eclipse:
right click your project > select properties
select "Resource" on the left
change text file encoding to UTF-8
Try this site http://www.string-functions.com/encodedecode.aspx
Try to find source charset
and end charset of your string
then replace this line in yuor code
out = new String(s.getBytes("CODE OF source charset"), "CODE OF end charset");
<media:group>
<media:content type="video/mp4"
url="http://cdn2.junctiontv.net/dmv/roku/ChiroDiniTumiJeAmar2997fps800kbpsForIPTV.mp4"
bitrate="800"
duration="8100"/>
</media:group>
<media:thumbnail
url="http://cdn2.junctiontv.net/dmv/images/ChiroDiniTumiJeAmar158x204.png"/>
I am trying to parse this xml using SAX Parser. But am getting error due to : in the tags. However if I replace remove : ie, change to its working fine. But problem is ,if I do this, am getting error in url as : is removed after http.
any solution?????????
Instead of using SAXparder, use
android.util.Xml.parse(InputStream,Xml.Encoding.ISO_8859_1, DefaultHandler);
to solve this problem...
This is an appropriate code. Adding this code to any SAX Parser code, xml containing http:// and https:// both can be parsed .
String text10=text9.replaceAll(":", ""); //text9 is any valid url with http:// or https:// or both
String text11="",text12="",text13="",text14="";
if(text10.contains("http//"))
{
text14=text10.replaceAll("http//", "http://");
}
if(text10.contains("https//"))
{
text14=text10.replaceAll("https//", "https://");
}
if(text10.contains("https//") && (text10.contains("http//")))
{
if(text10.contains("http//"))
{
text13=text10.replaceAll("http//", "http://");
}
if(text13.contains("https//"))
{
text14=text13.replaceAll("https//", "https://");
}
}
System.out.println("This is demo text " + text14);
Finally managed to do it.....in a round away process. It works fine if code contains only http://
String text2=text1.replaceAll(":", "");
String text3=text2.replaceAll("http", "http:");
Adding these two lines to my code,makes everything go fine.