I am trying to encode Arabic text to hex in order to send it to a POS printer.
byte[] bytes1 = Encoding.UTF8.GetBytes("عمر");
Array.Reverse(bytes1);
var hexString = BitConverter.ToString(bytes1);
hexString = hexString.Replace("-", "");
MyPrinter.PrintAr(hexString);
but I still get the wrong hex format that my printer understand. I need the format should look like:
\uFEA3
I also tried below code:
byte[] bytes1 = Encoding.Unicode.GetBytes("عمر");
Array.Reverse(bytes1);
int counter = 0;
var value="" ;
string var2 = "";
foreach (byte letter in bytes1)
{
// Get the integral value of the character.
// Convert the decimal value to a hexadecimal value in string form.
if (counter == 0)
{
counter = 1;
value = letter.ToString() ;
}
else
{
value += letter.ToString();
var2 = Convert.ToUInt16(value).ToString();
insert = "\\u" + var2;
counter = 0;
}
hexOutput += insert;
}
but still getting hex with number format like:
\u0669
Would you please help to get the right hex format for my printer.