Send escape character to printer

不打扰是莪最后的温柔 提交于 2019-12-06 04:06:52
const char ESC = '\x1B';

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 StringBuilder

You could

StringBuilder sb = new StringBuilder();
          sb.AppendLine();
          sb.AppendLine("<ESC>A");
          sb.AppendLine("H0050<ESC>V0100<ESC>L0303<ESC>XMSATO");
String output = sb.ToString().Replace("<ESC>", "\x1B")

e.g.

This should work

sb.AppendLine(((char)27).ToString());

For OPOS Drivers, I ended up using

string ESC = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27 }); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!