Jeff Verdegan wrote:
1. Not every value between 0 and 65535 is a valid Unicode character.
2. Even those that are valid characters are not valid in every encoding.
3. In general, you need to specify an appropriate encoding for your display app (looks like Windows cmd.exe, in this case) to use.
4. Even if your display tool is using the same encoding as what the character was written in, if the font that's being used to display the character does not have a glyph for that character, you'll get a default, such as a box or a question mark.
5. I haven't even looked at your getRandomChar() method, so there may be problems there.
6. Finally, just randomly generating characters and then displaying them in an arbitrary tool with an unspecified encoding and unspecified font is not a recipe for success. Perhaps if you could explain what you're actually trying to accomplish?
Marius Constantin wrote:6. I am just trying to display 175 characters selected randomly
Paul Clapham wrote:
Marius Constantin wrote:6. I am just trying to display 175 characters selected randomly
The question "Why?" still applies here.
Is there a purpose for this display? Is it important that you be able to choose Cyrillic and Coptic characters (just for example) and have them be displayed? If so then why did you choose to restrict your choices to only characters from the BMP of Unicode?
Campbell Ritchie wrote:Does Java™ directly use UTF-8 at all? I thought it used UTF-16 whenever there are chars greater than 0xffff.
Campbell Ritchie wrote:Does Java™ directly use UTF-8 at all? I thought it used UTF-16 whenever there are chars greater than 0xffff.
Consider Paul's rocket mass heater. |