Home Tutorial Java Corejava Convert String to unicode and ascii

 
 

Convert String to unicode and ascii
Posted on: April 15, 2010 at 12:00 AM
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:

Related Tags for Convert String to unicode and ascii:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.