How to remove a non-ascii character from CString
-
I find that some of the data I bring in has a character that looks like a space but is not a space. After much research, I identified the character as & then #160; If I put it together, it looks like a space in this message. How can I remove characters like this? I tried CString GetRidOf(CString str) { str.Remove(' '); return str; } but the remove function is not correct.
-
I find that some of the data I bring in has a character that looks like a space but is not a space. After much research, I identified the character as & then #160; If I put it together, it looks like a space in this message. How can I remove characters like this? I tried CString GetRidOf(CString str) { str.Remove(' '); return str; } but the remove function is not correct.
-
I find that some of the data I bring in has a character that looks like a space but is not a space. After much research, I identified the character as & then #160; If I put it together, it looks like a space in this message. How can I remove characters like this? I tried CString GetRidOf(CString str) { str.Remove(' '); return str; } but the remove function is not correct.
MSDN states[^] wrote:
This method does not modify the value of the current instance. Instead, it returns a new string in which all characters from position startIndex to the end of the original string have been removed.
So, assign the result of the function to a new string and return that, or return the result of the function.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
You could try
str.Remove('\xA0');
A0
is the hexadecimal representation of the decimal value 160. It should represent a non-breaking-space."Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."
That worked. Thank you very much.
-
MSDN states[^] wrote:
This method does not modify the value of the current instance. Instead, it returns a new string in which all characters from position startIndex to the end of the original string have been removed.
So, assign the result of the function to a new string and return that, or return the result of the function.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
That worked. Thank you very much.
-
The CString version does not work like the .NET one: CString::Remove[^]
"Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."