【问题标题】:Get a character from alt code (without keyboard events)?从 alt 代码中获取一个字符(没有键盘事件)?
【发布时间】:2012-04-27 01:06:24
【问题描述】:

我需要列出 alt 代码中的所有字符。 (如果您不知何故不知道那是什么,请按住 ALT 并在数字键盘上按一个,然后重复并按 2 等。)有没有办法在不使用键事件的情况下做到这一点?我到底要做的是这样的事情;

for (int i = 0; i < 10; i++) {
    Console.Write(KeyCode(i)); //Obviously KeyCode() doesnt actually exist, thats what im asking for :P
}

如果重要的话,我需要它与 Winforms 和 WPF 一起使用,并且控制台会很好,但我不需要它..

【问题讨论】:

    标签: c# keyboard char


    【解决方案1】:

    根据Wikipedia,以0开头的4位alt码对应Windows-1252字符集,3位码对应DOS code page 437

    【讨论】:

      【解决方案2】:

      我刚刚意识到你可以做到

      char aaaa = (char)i;
      //i is any alt code
      

      这是最好/唯一的方法吗,这是什么编码?

      【讨论】:

        猜你喜欢
        • 2015-02-09
        • 2015-11-10
        • 1970-01-01
        • 1970-01-01
        • 2018-01-23
        • 1970-01-01
        • 2014-02-01
        • 2021-07-29
        • 2018-04-14
        相关资源
        最近更新 更多