Convert String to unicode and ascii


 

Convert String to unicode and ascii

This tutorial demonstrate how a simple string can be converted to ascii and unicode.

This tutorial demonstrate how a simple string can be converted to ascii and unicode.

Description:

This example demonstrate how to convert the general string to unicode and ascii type

Code:

import java.net.IDN;

public class ChangeIdnType {
  public static void main(String[] args) {
    String general = "www.myWebsite.com";
    String ascii = IDN.toASCII(general);
    String unicode = IDN.toUnicode(general);

    System.out.println("General Format:" + general);
    System.out.println("Ascii Format):" + ascii);
    System.out.println("Unicode Format:" + unicode);
  }
}

Output:

Ads