Is there a way to have MySQL GROUP BY utilize trailing whitespace?
char values are space-padded when they are stored, so all trailing whitespace is assumed to be padding and removed when retrieving values.  varchar fields will retain trailing whitespace, but by default it is removed for comparisons.  (see The CHAR and VARCHAR types)

To retain the trailing whitespace for varchar values, use the binary operator.  Something like SELECT foo, CHAR_LENGTH(foo) FROM myTable
WHERE foo='bar'
GROUP BY BINARY foo should do what you want.