2

For example : If this is the name of the string ( Требования.xlsx ) , the encoded UTF-8 value of this string is (ТÑебованиÑ.xlsx) .

i need the java code that does this

I Used this site https://encoder.mattiasgeniar.be/index.php to get the encoded utf-8 value

kvm363
  • 21
  • 5

3 Answers3

0
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(myString)

Try this.

Hope this helps

nunovarela
  • 26
  • 8
  • Thank you for your help . I have tried your suggestion – kvm363 Aug 08 '19 at 14:07
  • String fileName = "Требования.xlsx"; //String decoded = new String(fileName.getBytes("ISO-8859-1")); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(fileName); System.out.println("DecodeD sTRING"+byteBuffer); – kvm363 Aug 08 '19 at 14:07
  • and it prints DecodeD sTRINGjava.nio.HeapByteBuffer[pos=0 lim=25 cap=33] – kvm363 Aug 08 '19 at 14:07
0

You can use:

URLEncoder.encode(value, StandardCharsets.UTF_8.toString());

to use URLEncoder

you have to import classes using
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.io.UnsupportedEncodingException;

refer to this site for example and more info https://www.urlencoder.io/java/

Islam Assem
  • 1,376
  • 13
  • 21
0
  • Just try it with "UTF-8" and if it is not working try it with "ISO-8859-1"
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
            new URL( URLEncoder.encode("add your string  URL here", "UTF-8") )
                    .openConnection().getInputStream()))) {
    } catch (Exception e) {
        e.printStackTrace();
    }
Dulaj Kulathunga
  • 1,248
  • 2
  • 9
  • 19