Dev: Tomcat and Oracle JDK 1.6 Test: WebSphere and IBM JDK 1.6
The string ends in a no-break space (U+00A0/#160) when submitted to the web service.
In Tomcat, the solution below works, however in WebSphere, the no-break space comes through as a (U+00C2/#194).
public static String removeWhiteSpace(String inputString) {
return inputString == null ? null : inputString.replaceAll("[\\s\\u00A0]+", "");
}
What would you have to do to make this work in both tomcat and WebSphere.
The solution we ended up going w/ was to replace both possible outputs:
\\u00C2\\u00A0
replaces the No-Break space in our WebSphere environment.
\\u00A0
replaces the No-Break space in our tomcat environment.
\\s
replaces any normal whitespace characters.
In the Java:
inputString.replaceAll("(\\u00C2\\u00A0|\\u00A0|\\s)+", "")
Downside:
In Tomcat, it is possible to accidentally replace a u00C2
character if it immediately precedes a no-break space. However, the risk was deemed acceptable.