Integer to Unicode

Had to iterate across a bunch of unicode chars and as such, needed to write this snippet of code to generate unicode from integers


....
	/**
	 * This method determines the unicode string representation of an integer
	 *
	 * @param num
	 *            The integer whose unicode string representation is required
	 * @return Unicode representation of the integer
	 */
	private static String IntToUnicodeString(int num)
			throws IllegalArgumentException {
		if (num  0x10FFFF)
			throw new IllegalArgumentException(Integer.toHexString(num)
					+ " is less than 0 or larger than the greatest unicode value 0x10FFFF");
		return new String(Character.toChars(num));
	}
....

~ by vinaybalamuru on October 7, 2008.

Leave a Reply

You must be logged in to post a comment.