ESC-POS-.NET
ESC-POS-.NET copied to clipboard
How to set the charsetcode? when I try to print chinese,it's show Garbled code
hey @alexzm19 there is not currently a way to print unicode characters, so you need to use a charset that's built in to the printer. Take a look at these issues for more information: #86 #67 . Give it a try and let me know how it goes!
hey @alexzm19 there is not currently a way to print unicode characters, so you need to use a charset that's built in to the printer. Take a look at these issues for more information: #86 #67 . Give it a try and let me know how it goes!
thank you for answer,I solved the problem step1: In .net core 3.1,.NET Core does not support GB2312 by default step2:Register encodingProvider on startup step3:Change print function return data.ToCharArray().Select(x => (byte)x).ToArray() => return Encoding.GetEncoding("GBK").GetBytes(data)
Glad we got you solved! @igorocampos this is a common question we get about printing nonstandard character codes. Perhaps we should put something about this in the README?
Yeah, sounds about right. In addition I do think we could make the Enconding changeable instead of hardcoded UTF-8. See the comment above, Alex had to change the Print method in order to place his own encoding in it. I think we can keep UTF-8 as default, but also let the user change it, if wanted.
I'll see if I can put a PR together about that.
Btw, I'm in the US now :)
@alexzm19 Can you describe with code what step2:Register encodingProvider on startup
means?
I wish to add this steps in the README.md in details. Thank you
of course Code: Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Link: https://learn.microsoft.com/zh-cn/dotnet/api/system.text.encoding.registerprovider?view=net-6.0
rainonheaert @.***
------------------ 原始邮件 ------------------ 发件人: "lukevp/ESC-POS-.NET" @.>; 发送时间: 2024年1月23日(星期二) 中午11:02 @.>; @.@.>; 主题: Re: [lukevp/ESC-POS-.NET] How to set the charsetcode? when I try to print chinese,it's show Garbled code (#88)
@alexzm19 Can you describe with code what step2:Register encodingProvider on startup means? I wish to add this steps in the README.md in details. Thank you
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
@alexzm19 thanks! I see you replied by email, but I think the link got lost when doing so. When you have the time, if could come back to Github and update your comment adding the URL for the link you mentioned, I'd appreciate it!
Ok, I just updated the comment, thanks for the reminder
rainonheaert @.***
------------------ 原始邮件 ------------------ 发件人: "lukevp/ESC-POS-.NET" @.>; 发送时间: 2024年1月23日(星期二) 中午11:21 @.>; @.@.>; 主题: Re: [lukevp/ESC-POS-.NET] How to set the charsetcode? when I try to print chinese,it's show Garbled code (#88)
@alexzm19 thanks! I see you replied by email, but I think the link got lost when doing so. When you have the time, if could come back to Github and update your comment adding the URL for the link you mentioned, I'd appreciate it!
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Thank you very much! That will do :)
Here's some more from the doc: