1

I have a russian string "этикетка". This is need to send to a web service, before sending to the web service i use encodeURIComponent to encode the string and it gives me:

'%D1%8D%D1%82%D0%B8%D0%BA%D0%B5%D1%82%D0%BA%D0%B0'

On the web service side is receive the string and decode it using the following code:

String strLbl = java.net.URLDecoder.decode(label);

but i don't get the string properly. It looses formatting and I get ѿтикетка. Can you please suggest how can i overcome this or what is the ideal way to send russian string

Thanks and regards

Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
Rohit
  • 401
  • 2
  • 4
  • 11

2 Answers2

1

As explained in the link given by NULL, decode(string) is now Deprecated in the favour of decode(string, encoding)

I would guess that the encoding and decoding method are not using the same page code.

Did you try to force UTF-8 during both process?

Aurélien Thieriot
  • 5,853
  • 2
  • 24
  • 25
0

I misunderstood your question be the formatting of it.

Use decodeURIComponent to decode url encoded strings in JavaScript:

> decodeURIComponent('%D1%8D%D1%82%D0%B8%D0%BA%D0%B5%D1%82%D0%BA%D0%B0')
"этикетка";

Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
  • No i am not decoding it in the browser. I want to decode it in java code since it call web service. I am using java.net.decode(label) but it not decoding it properly. Original string: этикетка after decoding i get: ѿтикетка – Rohit Jun 18 '13 at 11:20
  • 1
    I think he's asking how to decode the string correctly server-side, but correct me if I'm wrong. – Qantas 94 Heavy Jun 18 '13 at 11:20
  • URI class has no method for decoding an already encoded string. Can you please elborate how to do it using URI class – Rohit Jun 18 '13 at 11:29