Python treats non-breaking space wrong?

M

magnus.lycka

It seems that Python treats non-breaking space (\xa0) as a normal
whitespace character, e.g. when splitting a string. See below:
['hello', 'there']

Surely this is not intended behaviour?
 
S

Steven D'Aprano

It seems that Python treats non-breaking space (\xa0) as a normal
whitespace character, e.g. when splitting a string. See below:
['hello', 'there']

Surely this is not intended behaviour?


Yes it is.

str.split() breaks on whitespace, and \xa0 is whitespace according to the
Unicode standard. To put it another way, str.split() is not a word-
wrapping split. This has been reported before, and rejected as a won't-
fix.

http://mail.python.org/pipermail/python-bugs-list/2006-January/031531.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top