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));
	}
....
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s