String.Trim() removes more than need?

c#, string

Solution

160 is a NBSP (Non-breaking space) and according to the documentation, `Trim` will remove all the whitespace. 160 is classified in Unicode as whitespace.

You might want to call `Trim(' ')` instead.

Problem

I found a ticket in our issue tracker that one of customers report a bug that one texts is incomplete! We have a text conversion program from one legacy system(IBM AS400) to a modern one. I tracked it and found an unknown behavior on my code!! First see this: As you see, there is two char before first space (char32), but when i remove `Trim()`,the result is: Yes, `Trim()` removes char160 from beginning! What happened that `Trim()` works more than need? Note: both pictures are captured in same test state.

Original source