将转义字符发送到打印机
我正在开发一个 C# 应用程序,用于从 SATO (CG408 TT) 热转印打印机打印标签,
为此,我使用 SBPL(SATO 编程语言)。如下所示:
<ESC>A
<ESC>H0050<ESC>V0100<ESC>L0303<ESC>XMSATO
<ESC>H0050<ESC>V0200<ESC>B103100*SATO*
<ESC>H0070<ESC>V0310<ESC>L0101<ESC>XUSATO
<ESC>Q1<ESC>Z
为了与打印机通信并向其发送原始数据,我遵循此技术。首先,我尝试使用 StringBuilder 类构建转义序列。
StringBuilder sb = new StringBuilder();
sb.AppendLine();
sb.AppendLine("<ESC>A");
sb.AppendLine("H0050<ESC>V0100<ESC>L0303<ESC>XMSATO");
等等......
但是我如何替换字符串生成器参数中的
部分。我知道字符 27,但是如何将它与 AppendLine 命令一起使用
提前致谢。
I am developing an C# application to print labels from a thermal transfer printer from SATO (CG408 TT)
For this I am using SBPL (Programming language for SATO). Which looks something like following:
<ESC>A
<ESC>H0050<ESC>V0100<ESC>L0303<ESC>XMSATO
<ESC>H0050<ESC>V0200<ESC>B103100*SATO*
<ESC>H0070<ESC>V0310<ESC>L0101<ESC>XUSATO
<ESC>Q1<ESC>Z
To communicate with Printer and send raw data to it I am following this technique. At first i am trying to build the escape sequences using StringBuilder Class.
StringBuilder sb = new StringBuilder();
sb.AppendLine();
sb.AppendLine("<ESC>A");
sb.AppendLine("H0050<ESC>V0100<ESC>L0303<ESC>XMSATO");
and so on....
But how can I replace <ESC>
part in string builder argument. I know that character 27, but then how to use it with AppendLine Command
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
现在您可以像使用任何其他变量一样使用 ESC。请注意,您也可以将 esc 嵌入字符串中:
"\x1B"
但我认为这会变得笨拙(尤其是对于相邻的数字)。请不要
ESC + "somestring" + ESC
等,因为它违背了 StringBuilder 的目的
。
now you can use ESC like any other variable. Note that you can embed esc in a string as well:
"\x1B"
but I suppose that would become unwieldy (especially with adjacent numbers).Please do not
ESC + "somestring" + ESC
etc. because it defeats the purpose of the StringBuilderYou could
e.g.
这应该有效
This should work
对于 OPOS 驱动程序,我最终使用
For OPOS Drivers, I ended up using