Difference between ascii 160 and 32

0

my question originated when trying to compare 2 words of different origin, one of phpmyadmin and another of excel, that visually looked exact but when executing gave false

the difference can be seen in sublime

but then in which case 160 is used and in others 32 is

    
asked by junior 03.09.2018 в 16:21
source

1 answer

1

The difference between a "normal" space character (U + 0020) and a "non-breaking" space character (U + 00A0) is that when processing for HTML deployment, for example, or in some text editors there is a difference in the arrangement of the words when a line break can occur, for example, if you want the string 20 grados is maintained on a single line, that is, the text arrangement does not cause it to be displayed as

20

grados

in case the text exceeds the width of the screen after the 20 and that it carries grados to the next line.

With the use of the "non-breaking space" character (U + 00A0) to separate the words, it will be achieved that when the screen width is exceeded, the chain jump is made

20 grados

complete the next line and do not split into 2 lines of text.

This is the basic difference between ASCII 160 and 32, as you mention in the title of your question.

In the comparison you are making the result is false because the space characters are different after "9". For the comparison to result in true , as the comment of @Kilbunny says, you can replace the "non-breaking" space with the blank space before comparing the strings.

    
answered by 04.09.2018 / 02:05
source