简体   繁体   English

无法使用 CPCL 将土耳其语字符从 Xamarin.Forms 应用程序打印到 Zebra 移动打印机

[英]Unable to print Turkish characters from Xamarin.Forms application to Zebra mobile printer using CPCL

I am trying to print from a Xamarin.Forms application to Zebra ZQ220 mobile printer over bluetooth.我正在尝试通过蓝牙从 Xamarin.Forms 应用程序打印到 Zebra ZQ220 移动打印机。

I installed Zebra.Printer.SDK version 2.15.2634 and i am able to print.我安装了 Zebra.Printer.SDK 版本 2.15.2634,我可以打印了。

For Turkish character printing, i stored the font file SWISS721 in Zebra printer, and i am able to print Turkish characters via Zebra Setup Utilities / Open Communication With Printer / Direct Communication using my CPCL code, which is below.对于土耳其语字符打印,我将字体文件 SWISS721 存储在 Zebra 打印机中,并且我能够通过 Zebra Setup Utilities / Open Communication With Printer / Direct Communication 使用我的 CPCL 代码打印土耳其语字符,如下所示。

! 0 200 200 500 1
PCX 0 1 !<NRPLOGO.PCX
T SWF12.CPF 0 125 180  şŞ iİ üÜ ğĞ öÖ çÇ
T SWF08.CPF 0 1 225 Tarih : 01.01.2022     Makbuz No : NTQ4NzIzNTM=
PRINT

In Xamarin.Forms application, according to Zebra documentation, i created a string to store CPCL like below:在 Xamarin.Forms 应用程序中,根据 Zebra 文档,我创建了一个字符串来存储 CPCL,如下所示:

private const string RealTestLabelCpclSwiss = "! 0 200 200 500 1\r\n"
+ "PCX 0 1 !<NRPLOGO.PCX\r\n"
+ "T SWF12.CPF 0 125 180  şŞ iİ üÜ ğĞ öÖ çÇ\r\n"
+ "T SWF08.CPF 0 1 225 Tarih : 01.01.2022     Makbuz No : NTQ4NzIzNTM=\r\n"
+ "PRINT\r\n";

To send this string to printer, this needs to be converted to a byte array, and Zebra documentation uses UTF8 encoding like below:要将此字符串发送到打印机,需要将其转换为字节数组,Zebra 文档使用 UTF8 编码,如下所示:

return Encoding.UTF8.GetBytes(RealTestLabelCpclSwiss);

I can print to printer but Turkish characters like şŞ İ Ğ are not printed correctly.我可以打印到打印机,但土耳其语字符如 şŞ İ Ğ 打印不正确。

I assume this is an encoding issue, and i need to use maybe a different encoding, tried the encodings below:我认为这是一个编码问题,我可能需要使用不同的编码,尝试了以下编码:

return Encoding.Default.GetBytes(RealTestLabelCpclSwiss);

return Encoding.ASCII.GetBytes(RealTestLabelCpclSwiss);

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
return Encoding.GetEncoding(1254).GetBytes(RealTestLabelCpclSwiss);

return Encoding.GetEncoding("ISO-8859-9").GetBytes(RealTestLabelCpclSwiss);

But still i can't print Turkish characters with Xamarin.Forms.但我仍然无法使用 Xamarin.Forms 打印土耳其语字符。

My test device is an iPhone and i also checked the west checkbox in iOS project properties / iOS Build / Internationalization.我的测试设备是 iPhone,我还在 iOS 项目属性/iOS 构建/国际化中选中了 west 复选框。

How can i correct this encoding issue with Xamarin.Forms?如何使用 Xamarin.Forms 纠正此编码问题?

I resolved the issue.我解决了这个问题。 I used我用了

Encoding.GetEncoding("iso-8859-9")

instead of代替

Encoding.GetEncoding("ISO-8859-9")

and i am able to print Turkish characters.而且我能够打印土耳其语字符。

I didn't know this encoding name is case sensitive.我不知道这个编码名称区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 xamarin.forms 通过蓝牙打印机打印数据 - Print Data through bluetooth printer using xamarin.forms 在VS 2017中使用“使用xamarin.forms创建移动应用程序”电子书 - using “creating mobile apps with xamarin.forms” ebook with VS 2017 使用Xamarin.Forms在移动操作系统上创建带有Web界面的应用程序 - Create an app with web interface on mobile OS using Xamarin.Forms 如何使用Xamarin.Forms的Azure移动服务? - How to use Azure Mobile Services from Xamarin.Forms? 使用xamarin.forms在标签中使用各种语言特殊字符 - Use of various language special characters in labels using xamarin.forms Xamarin.Forms应用程序图标 - Xamarin.Forms application Icon 无法使用 C# 从 Xamarin.Forms 中的类构建数组 - Unable to build an array from a class in Xamarin.Forms with C# 如何使用tapGesture(Xamarin.Forms)从应用程序中的多个标签中删除所选标签 - how to delete a selected label from multiple labels in an application using tapGesture (Xamarin.Forms) 使用pubnub在xamarin.forms中进行一对一聊天应用程序 - One to One chat application in xamarin.forms using pubnub 使用xamarin.forms应用程序在编辑器中进行拼写检查 - Spell checking in editor using xamarin.forms application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM