Zebraプリンターで印刷するためのこのコードがあります(具体的にはRW 420)
StringBuilder sb = new StringBuilder();
sb.AppendLine("N");
sb.AppendLine("q609");
sb.AppendLine("Q203,26");
//set printer character set to win-1250
sb.AppendLine("I8,B,001");
sb.AppendLine("A50,50,0,2,1,1,N,\"zażółć gęślą jaźń\"");
sb.AppendLine("P1");
printDialog1.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
if (printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
byte[] bytes = Encoding.Unicode.GetBytes(sw.ToString());
bytes = Encoding.Convert(Encoding.Unicode, Encoding.GetEncoding(1250), bytes);
int bCount = bytes.Length;
IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(bCount);
System.Runtime.InteropServices.Marshal.Copy(bytes, 0, ptr, bytes.Length);
Common.RawPrinterHelper.SendBytesToPrinter(printDialog1.PrinterSettings.PrinterName, ptr, bCount);
}
RawPrinterHelper
ここから取得したMicrosoftのクラスです。
私の問題は、ASCII文字だけが次のように印刷されることです。
za g l ja
非ASCII文字がありません。
面白いことに、メモ帳を開いて同じテキストを入力し、Zebraプリンターで印刷すると、すべての文字に問題がありません。