• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java: help comparing unusual character windows/linux

lozina

Lifer
we make a call to a web service which returns XML data. In this data there is sometimes a special character (¤) which we need to be able to look for. In windows I can just say something like indexOf("¤") and it works fine. But this does not work in linux.

any idea how I would go about matching this character reliably in both windows and linux?
 
it makes no diff. the special character is there no matter what we parse it with. its part of the data
 
it's unicode is \u2021 and if I search for that in Windows it works but in linux it does not. Even though it is a single character in linux if I output it to logs it is printed out as 3 bizarre characters together.

edit: sorry for the confusion- I'm referring now to this char: ?, not the same as the one I was dealing with the other day. There are a couple more chars like that. in linux they turn into other characters. like the ? becomes equivalent to a ¥
 
I don't really understand why it worked, but what I did was I got the byte value of the character and then I just made a string like this:

String crossChar = new String(new byte[] { (byte)-121 });

that for example, is for the ? character

Now when I compare a string looking for that string it finds it both in linux and windows.

This did not work in linux: str.indexOf("?");
but this does: str.indexOf(crossChar);
and still works in windows too.

no idea why it works and why the old way didnt.

 
Back
Top