Generating Nepali Unicode Sequence For Characters

While I was working on a translation project for myself, I got into some localization phase. Since Nepali Characters are represented in unicode (u09xx), it was difficult to write Strings in this form. So, I wrote this class called unicode generator, where the input to this is common english keys used to write in nepali using romanized keyboard layout. This means, if you are going to write ‘Kushal’ in nepali, you would key in ‘kuSl’. Now, when you pass ‘kuSl’ to the format method of the following class, you will retrieve string like ‘u09xxu00xxu00xxu00xx’ where xx will be replaced by some number for correct characters. For instance, for the work ‘ka’ in Nepali, u0915 is the unicode. You can use this string to be displayed in GUI’s.

 *Converts from standard keyboard input to nepali unicode characters.
 *Written On: 12th November 2005
 *Author: Kushal Paudyal (
package com.kushal.utilities;

import java.util.Vector;
import javax.swing.JOptionPane;

public class UnicodeConverter {
	 * Declare a vector that will store all nepali unicode characters
	Vector unicodeVector;
	 * Declare and define a standard string that holds the
	 * keyboard input fornepali unicode sets in ascending order.
	 * There are some charaters forwhich no keys are assigned on
	 * the keyboard for their input. I have useddummy characters
	 * or their unicode values themselves in preparing the standard
         * string of keysets.

	 * Current faults discovered 123456789
         * u0944 u0945 u0946 u0949 u094A
	 * u094E u094F u0951 u0953 u0954
	static String standard = " 1234567890VM:u0904HA["+
		+ "u0912OWkKgG
		+ "u0934vSzsh`~aiIuURu0944u0945u0946eEu0949"
		+ "u094Aow/u094Eu094Fu0951|u0953u0954u0958u0959";

	String language;

	public UnicodeConverter(String language) {
		this.language = language;
		if (language == "np") {


	 * This method will take a string formed by proper keying for text that has
	 * to be converted into unicode. It will read the string characterwise and
	 * generate the index of that character from the standard string. Using this
	 * index, it will generate a corresponding nepali unicode from the
	 * unicodeVector.
	public String format(String str) {
		if (language == "np") {

			String formattedStr = "";
			for (int i = 0; i < str.length(); i++) {
				char temp = str.charAt(i);
				int index = standard.indexOf(temp);
				if (index < 0) // handle non-nepali characters
					System.out.println("no index found for " + temp);
					formattedStr += temp;
				} else {
					System.out.println("index for " + temp + " is:" + index);
					formattedStr += unicodeVector.elementAt(index);

			return formattedStr;
		} else
			return str;

	public void prepareVector() {
		unicodeVector = new Vector();

		 * Keep all the nepali unicode characters in the vector
		unicodeVector.addElement(" "); // space
		unicodeVector.addElement("u0966"); // zero
		unicodeVector.addElement("u0967"); // one
		unicodeVector.addElement("u0968"); // two
		unicodeVector.addElement("u0969"); // three
		unicodeVector.addElement("u096A"); // four
		unicodeVector.addElement("u096B"); // five
		unicodeVector.addElement("u096C"); // six
		unicodeVector.addElement("u096D"); // seven
		unicodeVector.addElement("u096E"); // eight
		unicodeVector.addElement("u096F"); // nine
		unicodeVector.addElement("u0905"); // a
		unicodeVector.addElement("u0906"); // aa
		unicodeVector.addElement("u0907"); // i
		unicodeVector.addElement("u0908"); // ii
		unicodeVector.addElement("u0909"); // u
		unicodeVector.addElement("u090A"); // U
		unicodeVector.addElement("u090B"); // vocalic R (ri)
		unicodeVector.addElement("u090C"); // vocalic L (lri)
		unicodeVector.addElement("u090D"); // candra E
		unicodeVector.addElement("u090E"); // short E
		unicodeVector.addElement("u090F"); // E
		unicodeVector.addElement("u0910"); // AI
		unicodeVector.addElement("u0911"); // candra o
		unicodeVector.addElement("u0912"); // short o
		unicodeVector.addElement("u0913"); // O
		unicodeVector.addElement("u0914"); // AU
		unicodeVector.addElement("u0915"); // ka
		unicodeVector.addElement("u0916"); // kha
		unicodeVector.addElement("u0917"); // ga
		unicodeVector.addElement("u0918"); // gha
		unicodeVector.addElement("u0919"); // nga
		unicodeVector.addElement("u091A"); // cha
		unicodeVector.addElement("u091B"); // chha
		unicodeVector.addElement("u091C"); // ja
		unicodeVector.addElement("u091D"); // jha
		unicodeVector.addElement("u091E"); // nya
		unicodeVector.addElement("u091F"); // tta
		unicodeVector.addElement("u0920"); // ttha
		unicodeVector.addElement("u0921"); // dda
		unicodeVector.addElement("u0922"); // ddha
		unicodeVector.addElement("u0923"); // nna
		unicodeVector.addElement("u0924"); // ta
		unicodeVector.addElement("u0925"); // tha
		unicodeVector.addElement("u0926"); // da
		unicodeVector.addElement("u0927"); // dha
		unicodeVector.addElement("u0928"); // na
		unicodeVector.addElement("u0929"); // nna
		unicodeVector.addElement("u092A"); // pa
		unicodeVector.addElement("u092B"); // pha
		unicodeVector.addElement("u092C"); // ba
		unicodeVector.addElement("u092D"); // bha
		unicodeVector.addElement("u092E"); // ma
		unicodeVector.addElement("u092F"); // ya
		unicodeVector.addElement("u0930"); // ra
		unicodeVector.addElement("u0931"); // rra
		unicodeVector.addElement("u0932"); // la
		unicodeVector.addElement("u0933"); // lla
		unicodeVector.addElement("u0934"); // llla


	 * Usage Example
	public static void main(String args[]) {
		UnicodeConverter generator = new UnicodeConverter("np");
		 * Usage: If you want to print mero naam Kushal ho, you would be keying
		 * in the following for romanized unicode keyborads mero nam kuSl ho
		// String test = generator.format("raz/q/riy"); // Rastriya
		String test = generator.format("mero nam kuSl ho");
		JOptionPane.showMessageDialog(null, test);


[My Video Promotion]
  1. How to extract plain Text from HTML Website easily in Java
  2. How To Find What Java Version You Are Using?
  3. Computing the total, free and usable disk space easily using JDK 1.6
  4. Creating and java.util.sql objects from Calendar object
  5. Bar Code Generation In Java Using iText API
  6. Simple Tag Generator In Java For Music Blogs
  7. Tutorial on Converting an List of Strings or Numbers to a CSV file with optional sorting
  8. Calling URL Browser From Java Application
  9. Java Reflection Tutorial – List Methods Of A Class
  10. Cleaning Punctuation And White Spaces From A String
  11. Java Tutorial – Using JCIFS to copy files to shared network drive using username and password
  12. Prime Number Finder In Java
  13. Utility Class For Getting SQL Connection and Closing It
  14. Java Design Pattern – Singleton Pattern
  15. Reading / Writing File in Java and String Manipulation
  16. How to capture a screenshot using Java and save it to a file?
  17. Calculating The Difference Between Two Dates In Terms of Months
  18. Getting The Name Of Currently Logged In User In The System
  19. How To Set And Get System Clipboard Contents In Java
  20. RGB To Hex and Hex To RGB Conversion Using Java and Regular Expressions
  21. Generating Nepali Unicode Sequence For Characters
  22. Java Tool To Compare Two Lists and Spit Out The Differences – Working Example
  23. Replacing non-ASCII characters using Java Regular Expressions
  24. Calculating Folder Size In Java
Tagged , , , , , , , , . Bookmark the permalink.

3 Responses to Calculating Folder Size In Java

  1. Pingback: » Latest Updates

  2. Jamie says:

    This approach uses less memory:

    public static class SizeCounter implements FileFilter
    private long total = 0;
    public SizeCounter(){};
    public boolean accept(File pathname) {
    if ( pathname.isFile()) {
    } else {
    return false;
    public long getTotal()
    return total;

    private static long getFileOrDirectorySize(File file) {
    SizeCounter counter = new SizeCounter();
    return counter.getTotal();

  3. kushalzone says:

    Thank you Jamie for your optimized solution.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.