I have a TreeSet of values. One value contains an apostrophe. When the contents of the TreeSet are listed, instead of an apostrophe, it displays another character. I tried changing the TreeSet to an ArrayList, with the same result. How do I get around this?
I really need the output to match what I have listed above. Any tips are greatly appreciated. Thanks in advance.
verduka fox wrote:Are there any other ways to make this work? This is urgent, so I appreciate your responses.
At the command line? No. If you're writing a command-line application and you have to support characters outside of whatever your shell supports, you're out of luck.
But are you writing a command-line application? If you aren't, then don't use the shell to do that sort of testing. It just confuses things. Use whatever medium the application is targeting (Swing GUI, web app, whatever) to do that testing.
My code is actually running on WebSphere Portal on AIX. When it runs there, the apostrophe is displayed as a question mark '?' instead of an apostrophe. When I'm debugging this on Windows, Windows displays the apostrophe as Æ. In either case, the apostrophe I specify in the code is not displayed as such. How do I get the code when run to display what is actually written in the code?
PS Sorry for the urgent comment. I didn't mean to upset anyone.
William Brogden wrote:Looking back at how I solved the problem, I used the String replace function - which is faster - like this:
I would actually not use String.replace but loop. Your code loops over the String 12 times, potentially creating 12 new Strings. One single loop will suffice:
As in your code, replacing another character is easy: just add one case statement with replacement.