Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GB18030 simplified chinese #86

Closed
koo9 opened this issue Oct 29, 2020 · 5 comments
Closed

GB18030 simplified chinese #86

koo9 opened this issue Oct 29, 2020 · 5 comments

Comments

@koo9
Copy link

koo9 commented Oct 29, 2020

did anybody manage to print chinese simplified character with this lib? if so, any code example please. thx

@lukevp
Copy link
Owner

lukevp commented Oct 29, 2020

Hey @koo9 as far as I know, the only Asian character set printed so far is Katakana. Simplified Chinese likely needs to be enabled, but it's pretty straightforward to add new command sets to the library. Please feel free to open a PR! Check out this link for a similar issue

@koo9
Copy link
Author

koo9 commented Oct 29, 2020

yes, it's a matter of adding codepage to the codepage enum. or add an extension method for that. I am using xprinter. it supports GB18030 encoding.

@koo9
Copy link
Author

koo9 commented Oct 29, 2020

Ok found a solution for that. see original solution here: https://stackoverflow.com/questions/1941988/printing-simplified-chinese-characters-on-epson-tm-t88ivm Im using Xprinter which supports GB18030 Simplified Chinese characters. so by default it's set to that codepage. in order to print chinese character, we need to encode the string properly like so:

       string text = "中文菜单";
        var encoding = System.Text.Encoding.GetEncoding("GB18030");
        byte[] bytes = encoding.GetBytes(text);
        string isoString = Encoding.GetEncoding("ISO-8859-1").GetString(bytes);

        var e = new EPSON();
        printer.Write(ByteSplicer.Combine(
            e.Initialize(),
            //e.CodePage(CodePage.CHINA),
            e.PrintLine(isoString),
            e.FullCut()
        ));

No need to set the codepage here and I don't think the current implementation have the codepage for that. the key here is to convert the string inot ISO-8859-1 encoded string.

PS: for .net core, looks like it only support a few codepage. if you need GB18030, you need to use the full .net framework.

Hope that helps others.

@xklake
Copy link

xklake commented Jan 30, 2023

yes, it's a matter of adding codepage to the codepage enum. or add an extension method for that. I am using xprinter. it supports GB18030 encoding.

i am also using xprinter N160i wifi printer, but this GB18030 is not found and throws an exception, does model relate or code issue?

Thanks

@koo9
Copy link
Author

koo9 commented Jan 30, 2023

@xklake xprinter is made by a chinese company so I would think it will support GB18030 character set. please consult the user manual or the related document to confirm that. one easy way to find that out is to print a self test page by holding down the paper feed button for 3 seconds while turning on the printer

btw I am using xprinter model XP-80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants