Share on Google+Share on Google+

Convert String to unicode and ascii

Advertisement
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

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.