我遇到一個問題,如果我傳遞一個硬編碼字符串\x1B|200uF
作爲參數,該命令會正確接受它。字符串中的轉義序列
但是,當我檢索XML元素相同的值到一個新的字符串變量,我得到以下值:\\x1B|200uF
正如你可以看到有一個額外的轉義序列。
因此,在總結問題:
using (XmlReader xmlReader = XmlReader.Create(@"PosPrinter.xml"))
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
switch (xmlReader.Name)
{
case "PosPrinter":
_printer.LogicalName = xmlReader.GetAttribute("LogicalName");
break;
case "FeedReceiptCommand":
_printer.FeedReceiptCommand = xmlReader.GetAttribute("value");
break;
我值檢索到我的「FeedReceiptCommand」字符串正如我上面提到的值存儲在XML作爲\x1B|200uF
但檢索到的字符串作爲\\x1B|200uF
與在開始時額外的轉義序列。
我然後使用字符串變量FeedReceiptCommand打電話給我的命令:
_posPrinter.PrintNormal(PrinterStation.Receipt, PrinterSettings.FeedReceiptCommand);
但由於額外的轉義序列的命令不執行。
但如果我叫用值相同的命令硬編碼:
_posPrinter.PrintNormal(PrinterStation.Receipt, "\x1B|200uF");
...然後命令被成功執行..
價值\x1B|200uF
是ESC命令使用Microsoft.PointOfService發送給Epson TM-T88V打印機,其中'\ x'是用於Hex的,我認爲1B是Hex值。
我hav e試圖通過使用'Trim','Substring',甚至做一個foreach循環來循環字符串中的每個字符以建立一個新字符串來擺脫額外的轉義序列。我也嘗試過stringbuilder。
但我錯過了這裏的某處。
因此,任何幫助會中我如何在地方\x1B|200uF
您能得到什麼,如果你打印出價值?我確信''''只是一個顯示器。 – ChrisF 2013-02-13 23:04:56