开发者

Java UrlDecode not wotking when we send encoded value from URl

When we initialize the string in class with same value i开发者_开发技巧t decodes it properly.When get same string from url it is not able to decode it.We are using "UTF-8".Below is the code for doing it.Any Suggestions.

public static void main(String args[]){
  SendSMS sendSMS = new SendSMS();
  sendSMS.sendSMS("", "");

  try{
     String sms="#E0#A4#B8#E0#A5#81#E0#A4#B6#E0#A4#BF#E0#A4#B2#20";
 sms=sms.replaceAll("#","%");        
  System.out.println( URLDecoder.decode(sms,"utf8"));

  }catch(Exception e){e.printStackTrace();}

  }
}

It works properly.

 System.out.println("actural sms ="+sms);
      sms=sms.replaceAll("#","%");
   System.out.println("compared"+sms.equals("%E0%A4%B6%E0%A4%B0%E0%A4%A6%20"));
     log.info("sms before formating= ");
     log.info(sms.trim());
 System.out.println( URLDecoder.decode(sms,"utf8"));





    in.close();*/

 }catch(Exception e){
     log.error("error occured while sending message:-"+e.getMessage());
     e.printStackTrace();
     }

Here it is not working properly.The output of .equals() is true..Yet the decoder gives ?????..


The output of .equals() is true

No, it's not.

Yet the decoder gives ?????

For me it gives सुशिल

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜