-1

Hi i have strange problem. Here is my code:

string tmp = "20_29\u0013";

How can I get rid of that "\u0013"?


Normally I will do it with substring or something but I have some issues with that character ---> \
Could someone help me?

Brarord
  • 611
  • 5
  • 18
  • Where did this come from? `\u0013` is an escape sequence representing the carriage return character – Panagiotis Kanavos Jul 21 '20 at 10:18
  • It is from my client which is sending data to my server. TCP\IP – Brarord Jul 21 '20 at 10:19
  • 4
    technically, `tmp = tmp.Replace("\u0013", "");` where `"\u0013"` is in fact a single character with `0x0013` code: `'\r'`. Another possibility is `tmp = tmp.TrimEnd();` which removes white spaces (`'\r'` included) from the end of the string – Dmitry Bychenko Jul 21 '20 at 10:19
  • 2
    Does the *client* send `\`, `u`, `0`, `0`, `1`, `3` ? Or a single `0x13` byte? This escape sequence is a carriage return, also represented as `\r`. In all single-byte code pages *and* UTF8 it's represented by a single byte, `0x13`. You can remove it from the end of any string with `Strings.TrimEnd('\r', '\n');` – Panagiotis Kanavos Jul 21 '20 at 10:23
  • That trimEnd won't work :( – Brarord Jul 21 '20 at 10:26

1 Answers1

2

You can use tmp.TrimEnd('\u0013') if it is single char or tmp.Replace("\\u0013", string.Empty) if it is sequence of chars to get "20_29" part:

satma0745
  • 667
  • 1
  • 7
  • 26