-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?

5
  • Where did this come from? \u0013 is an escape sequence representing the carriage return character Commented Jul 21, 2020 at 10:18
  • It is from my client which is sending data to my server. TCP\IP Commented Jul 21, 2020 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 Commented Jul 21, 2020 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'); Commented Jul 21, 2020 at 10:23
  • That trimEnd won't work :( Commented Jul 21, 2020 at 10:26

1 Answer 1

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:

Sign up to request clarification or add additional context in comments.

4 Comments

Everything is a Unicode character. This particular character though is an ASCII character - a carriage return \r
Yes, I mean that '\u0013' is one solid character (not string of characters), so you can use IndexOf on it
Or use TrimEnd
Yes, TrimEnd is perfect choice here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.