commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Downey <>
Subject [lang]Bug in StringUtils.deleteWhitespace()
Date Thu, 26 Sep 2002 16:50:05 GMT
I'm going through StringUtils, doing some doc cleanup. eg adding throws 
NullPointerException where a method will, and saying what will happen where 
it won't. 
I was going to add a note to this method, documenting which definition of 
whitespace was being used, when I realised something. The set of characters 
that deleteWhitespace cuts from a string doesn't match ANY of Java's 
definintions of whitespace.
It will trim 
    ' ' - space
    '\t' - horizontal tab
    '\r' - carriage return
    '\n' - line feed
    '\b' - backspace

Backspace isn't a whitespace character. Formfeed, on the other hand, is. And 
this is ASCII (ISO-LATIN-1) only, Unicode has a superset definition of 

I think the definition should be changed to: (cut and paste from javadoc for 
	'\n' '\u000A'  NEW LINE  
	'\f' '\u000C'  FORM FEED  
	'\r' '\u000D'  CARRIAGE RETURN  
	' ' '\u0020'  SPACE

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message