7

I've been bored, so I tried to make a program that writes a Look of Disapproval smiley(the ಠ_ಠ face) when pressing ctrl+shift+L. Now everything works, except for the underscore that is in the smiley, which won't get written at all.

This was what I used first:

SendKeys.Send("ಠ_ಠ");

I've tried various things, like adding {} brackets around the underscore, and of course I googled this too.

Is there any way I can get the underscore to get sent?

Thanks in advance.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
JeremyG
  • 71
  • 2

2 Answers2

1

Mixing different encodings creates weird result. is Unicode, _ is ASCII. Different length characters confuse and iritate Visual Studio.

Try:

SendKeys.Send("\u0CA0_\u0CA0");

Or:

SendKeys.Send("\u0CA0\u005F\u0CA0");
MPelletier
  • 16,256
  • 15
  • 86
  • 137
  • 3
    That means even though you can type "ಠ_ಠ", that's not interpreted as "ಠ_ಠ", because Visual Studio sees: Unicode, then expects more Unicode and finds something which isn't. The end result makes you *feel* just like your input: ಠ_ಠ. – MPelletier Nov 21 '11 at 19:39
  • 2
    Wrong. Any decent encoding system will handle that fine. – SLaks Nov 21 '11 at 19:55
  • @SLaks I never said Unicode was decent. :) But seriously, it's a limitation on interpretation of Unicode by VS. Would you agree? – MPelletier Nov 21 '11 at 20:00
  • @SLaks I would find find it very surprising that would give the OP a different result. I actually get `ಠ_ಠ` fine from using "ಠ_ಠ", but only because I'm on some funky un-English keyboard (VS and Windows are in English though). – MPelletier Nov 21 '11 at 20:19
  • 1
    The keyboard layout has nothing to do with file encodings. UTF8 is a robust encoding that can handle any valid sequence of characters. **This will work on a source level**. I have no idea what the problem is. – SLaks Nov 21 '11 at 20:22
  • I tried this, and it still didn't write the underscore. And testing it with the messagebox in fact _did_ write it. – JeremyG Nov 21 '11 at 20:22
  • `var form = new Form(); form.Click += delegate { SendKeys.Send("ಠ_ಠ"); }; form.Controls.Add(new TextBox()); Application.Run(form);` – SLaks Nov 21 '11 at 20:24
  • @JeremyG What are you sending your characters *to* when doing ctrl+shift+l? – MPelletier Nov 21 '11 at 20:28
  • Weird, maybe it's just a problem on my part, in which case some computers would be able to do this and some aren't. – JeremyG Nov 21 '11 at 20:30
  • @MPelletier You mean, as that I'm sending it into notepad? – JeremyG Nov 21 '11 at 20:31
  • @JeremyG So maybe your problem is with notepad. I tried a project where I just send it to the textbox in a form (on Enter). Can you try that? – MPelletier Nov 21 '11 at 21:58
  • @MPelletier: I don't get it. AFAIK either the source file is unicode or it isn't, so how can the underscore be ASCII? – Brian Rasmussen Nov 22 '11 at 04:45
0

If you don't use an english keyboard layout that has the underscore as key you can't just type the ASCII character but have to write it as a combination of modifier and character keys.

foowtf
  • 399
  • 1
  • 9