Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Non-breaking space

 
Kowshik Nandagudi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came up with this issue.


output: B=         3+monthly(A,'mean')+3;C=B;'thisisacomment+3meansadding3

source.replaceAll("\\s",""); is replacing space with ascii value 32 and not non breaking space with ascii value 160.

I can replace it by checking for ascii value of each character and replace 32 and 160.

Is there any way I can replace any space using String functions

Thanks in advance
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When it comes to printing to the console as you are doing there is no such character as a "non breaking space" and it is not normally needed since the console normally has a fixed width font and no interpretation is done that can in any way merge groups of spaces into just one space.

P.S. The ASCII characters have a range from 0x00 to 0x7e so 160 is not an ASCII character.
 
Kowshik Nandagudi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you James.

I found this problem when my team member pasted the string "B = 3 + monthly(A,'mean')+3;C= B;'this is a comment +3 means adding 3" using a messenger. Found it strange in the beginning. and started printing the ascii value of each character using

It was printing 160 for the spaces after " = " character in the input string.

Verified the character for value 160 in Extended ASCII table and found it to be non breaking space.

Was just thinking this kind of scenarios can occur in real time .
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I must be missing something. So all you are trying to do is replace the 160 chars with a space.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic