2

Or more specifically. The Ascii control character. ^C, 0x03, or STX. I am trying to get my program to send out color codes in IRC ( I know there is not really a standard for this ), but I am a atleast an hour into research, and I don't know what else to search for. And I don't see anything in VS 2010's options.

Link to ascii reference.

All I need to get VS to stop being dumb, and let me input into the text editor the STX or ETX characters. I did already try the encoding in the save as. Any thoughts or ideas please?

Tony Arnold
  • 649
  • 2
  • 7
  • 15
  • Use appropriate escape sequences instead? – wilx Jan 17 '15 at 23:22
  • Are these [ETX characters](http://en.wikipedia.org/wiki/End-of-text_character) inside C# string literals, `" ... "`? – Jeppe Stig Nielsen Jan 17 '15 at 23:28
  • These three close votes are wrong. The OP should have shown that he was trying to use control codes in C# code, but it's not a debugging issue - it's an IDE issue and a language issue. – John Saunders Jan 17 '15 at 23:33
  • @Tony: did you try to just type in the codes? Is that what you're saying you want to "turn on"? Please show the line of code where you wanted to get the ETX code. – John Saunders Jan 17 '15 at 23:33
  • Well, originally I was taking the characters from another source, copying and trying to paste them into the editor, which showed nothing. Save for some invisible characters, and having the compiler freak out on me. Heh. That was where I was getting my issue I was mentioning above. Sorry for the confusion. My lack of understanding what was happening. – Tony Arnold Jan 17 '15 at 23:39

1 Answers1

7

You can encode any character using escape sequences:

string s = "\x03"; // note: hexadecimal value

While it is technically possible to get at least some special characters directly in a string, it will be completely hopeless to make sense of since they can't be displayed properly.

Full list (swiped from this page):

\' - single quote, needed for character literals
\" - double quote, needed for string literals
\\ - backslash
\0 - Unicode character 0
\a - Alert (character 7)
\b - Backspace (character 8)
\f - Form feed (character 12)
\n - New line (character 10)
\r - Carriage return (character 13)
\t - Horizontal tab (character 9)
\v - Vertical quote (character 11)
\uxxxx       - Unicode escape sequence for character with hex value xxxx
\xn[n][n][n] - Unicode escape sequence for character with hex
               value nnnn (variable length version of \uxxxx)
\Uxxxxxxxx   - Unicode escape sequence for character with hex
               value xxxxxxxx (for generating surrogates)
Chris
  • 5,442
  • 17
  • 30
  • Hmm I see. I was using `\0x03`. That might explain my issue. Heh. Thanks! – Tony Arnold Jan 17 '15 at 23:42
  • 1
    The ETX character is permitted directly inside the `"..."` string literal because it is not classified as a *new-line-character* in the C# specification. I do not know if Visual Studio will present it in a nice way, like some text editors. Of course it is good advice to use `"\x3"` or `"\u0003"`. If you use less than four hex digits with the `\x` form, be sure the next character is not 0-9 or A-F. – Jeppe Stig Nielsen Jan 17 '15 at 23:55
  • I was doing: `"\x03"+"Some text here"` string, to separate the sequence from everything else. – Tony Arnold Jan 18 '15 at 00:08