Convert String to unicode and ascii

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

 
 

Share on Google+Share on Google+

Convert String to unicode and ascii

Ads

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:

Advertisements

Posted on: April 15, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles