private void button1_Click(object sender, EventArgs e) { Open(); string str = "نص"; string str1 = ToHexString(str); textBox1.Text = str1; StringBuilder receipt = new StringBuilder(); receipt.Append("\x1B\x40"); // Initialize Printer receipt.Append("\x1B\x74\x28"); // Select Arabic code page (Page 40,1256) receipt.Append(str1); // The Arabic text to be printed receipt.Append("\x0A"); // Print and line feed receipt.Append("\x1D\x56\x42\x00"); // Select cut mode and cut paper string szString = receipt.ToString(); PrintText(Printer, szString); } public string ToHexString(string str) { var sb = new StringBuilder(); var encoding = Encoding.GetEncoding(1256); var bytes = encoding.GetBytes(str); foreach (var t in bytes) { sb.Append(t.ToString("X2")); } return sb.ToString(); }
str1
receipt.Append("\xE4\xD5")
receipt.Append("\\xE4\\xD5")
receipt.Append(@"\xE4\xD5")
receipt.Append("E4D5")
ToHexString
sb.Append((char)t);
foreach (var t in bytes) { sb.AppendFormat("\\x{0:X2}", t); }
@"\x{0:X2}"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)