limit jtextfield to a specific codepage

Hi

In my application some text is edited, saved as XML and sent to a device that does not understand unicode. Therefore I need a way to make sure that only characters included in a specific codepage is entered?

I'm using the Xerces xmlserialize class to serialize the xml document, and set the encoding on the OutputFormat object.

Best regards

Mads

[380 byte] By [mwa-doms-dka] at [2007-10-1 21:11:41]
# 1
Could you use Character.UnicodBlock to test whether each character is a member of the character block you can support? http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/lang/Character.UnicodeBlock.html
one_danea at 2007-7-13 3:08:41 > top of Java-index,Desktop,I18N...
# 2
Or encode each character using that code page, then decode it again, and if you get something different then the code page doesn't support the character?
DrClapa at 2007-7-13 3:08:41 > top of Java-index,Desktop,I18N...
# 3
As suggested by getBytes(): http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#getBytes()you could use a CharsetEncoder object which has a method called canEncode()
horiniusa at 2007-7-13 3:08:41 > top of Java-index,Desktop,I18N...
# 4
Thanks everyone for your replies.I'm going with the back and forth conversion - the strings are small, so it seems like a good and easy way to go.-Mads
mwa-doms-dka at 2007-7-13 3:08:41 > top of Java-index,Desktop,I18N...