views:

129

answers:

0

I have cases where user-entered data from an html textarea or input is sometimes sent with \u00a0 (non-breaking spaces) instead of spaces when encoded as utf-8 json.

I believe that to be a bug in Firefox, as I know that the user isn't intentionally putting in non-breaking spaces instead of spaces.

There are also two bugs in Ruby, one of which can be used to combat the other.

For whatever reason

\s

doesn't match

\u00a0 

However

[^[:print:]]

(which definitely should not match) and

\xC2\xA0

both will match, but I consider those to be less-than-ideal ways to deal with the issue.

Are there other recommendations for getting around this issue?