Windows - 控制台输出是否会无意中导致系统发出蜂鸣声?

发布于 2024-07-24 07:03:20 字数 302 浏览 8 评论 0原文

我有一个 C# 控制台应用程序,它向控制台记录很多内容(使用 Trace)。 它记录的一些内容是网络消息的压缩表示(因此其中很多内容被呈现为时髦的非字母字符)。

应用程序运行时,我经常听到系统蜂鸣声。 是否有可能是我写入控制台的某些“文本”导致了这些问题?

(我所说的系统蜂鸣声是指 PC 机箱内的低技术扬声器发出的声音,而不是任何类型的 Windows 声音方案 WAV)


如果是这样,有什么方法可以为我的应用程序禁用它吗? 我希望能够输出任何可能的文本,而不会将其解释为声音请求。

I have a C# console application that logs a lot to the console (using Trace). Some of the stuff it logs is the compressed representation of a network message (so a lot of that is rendered as funky non-alphabetic characters).

I'm getting system beeps every so often while the application is running. Is it possible that some "text" I am writing to the console is causing them?

(By system beep, I mean from the low-tech speaker inside the PC case, not any kind of Windows sound scheme WAV)


If so, is there any way to disable it for my application? I want to be able to output any possible text without the it being interpreted as a sound request.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

洋洋洒洒 2024-07-31 07:03:21

这通常是由于输出字符代码 7、CTRL-G(即 BEL(响铃)字符)引起的。

购买新电脑或主板时,我通常要做的第一件事是确保主板到扬声器的电线没有连接。 自从 Commander Keen 时代以来,我就没有使用过扬声器(移除那根电线是与操作系统无关的停止声音的最佳方法:-)。

That's usually caused by outputting character code 7, CTRL-G, which is the BEL (bell) character.

The first thing I normally do when buying a new computer or motherboard is to ensure the wire from the motherboard to the speaker is not connected. I haven't used the speaker since the days of Commander Keen (and removing that wire is the best OS-agnostic way of stopping the sound :-).

苍白女子 2024-07-31 07:03:21
HKEY_CURRENT_USER\Control Panel\Sound

将“蜂鸣”键设置为“否”。

HKEY_CURRENT_USER\Control Panel\Sound

set the "Beep" key to "no".

何以心动 2024-07-31 07:03:21

当然,如果您将 ASCII 控制代码“Bell”(0x7) 输出到控制台,它会发出蜂鸣声。

absolutely, if you output ASCII control code "Bell" (0x7) to a console, it beeps.

留一抹残留的笑 2024-07-31 07:03:21

如果您不想发出蜂鸣声,则必须在输出之前替换 0x7 字符,或者禁用“Beep”设备驱动程序,您可以在“非即插即用驱动程序”部分中找到该驱动程序,如果您打开“显示隐藏设备”选项。 或者把喇叭拿出来。

If you don't want if to beep, you'll either have to replace the 0x7 character before outputting it, or disable the "Beep" device driver, which you'll find in the Non-Plug and Play Drivers section, visible if you turn on the Show Hidden Devices option. Or take the speaker out.

怪我入戏太深 2024-07-31 07:03:21

即使您检查输入的 BELL 字符,它仍然可能发出蜂鸣声。 这是由于字体设置和 unicode 转换造成的。 有问题的字符是 U+2022,子弹。

Raymond Chen 解释

在 OEM 代码页中,项目符号字符正在转换为
嘟。 但这是为什么呢?

您看到的是相反的MB_USEGLYPHCHARS。 迈克尔·卡普兰
不久前讨论过MB_USEGLYPHCHARS。 它决定是否某些
字符应被视为控制字符或可打印
转换为 Unicode 时的字符。 例如,它控制
ASCII 响铃字符 0x07 是否应转换为
Unicode 响铃字符 U+0007 或 Unicode 项目符号 U+2022。 你
需要 MB_USEGLYPHCHARS 标志来决定何时走哪条路
转换为 Unicode,但没有相应的歧义
从 Unicode 转换。 从 Unicode 转换时,U+0007 和
U+2022 映射到 ASCII 响铃字符。

Even if you check the input for BELL characters, it may still beep. This is due to font settings and unicode conversion. The character in question is U+2022, Bullet.

Raymond Chen explains:

In the OEM code page, the bullet character is being converted to a
beep. But why is that?

What you're seeing is MB_USEGLYPHCHARS in reverse. Michael Kaplan
discussed MB_USEGLYPHCHARS a while ago. It determines whether certain
characters should be treated as control characters or as printable
characters when converting to Unicode. For example, it controls
whether the ASCII bell character 0x07 should be converted to the
Unicode bell character U+0007 or to the Unicode bullet U+2022. You
need the MB_USEGLYPHCHARS flag to decide which way to go when
converting to Unicode, but there is no corresponding ambiguity when
converting from Unicode. When converting from Unicode, both U+0007 and
U+2022 map to the ASCII bell character.

度的依靠╰つ 2024-07-31 07:03:21

如果未在操作系统级别禁用,输出字符串中的 \b 将引起蜂鸣声。

\b in output string will cause beep, if not disabled on the OS level.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文