Malform encoding when connect printer with dll

Background

Recently, our company received a project, to help scenic sell tickets. I have to develop ticket print function.

Progress

Any Problem?

Our client have an existing system, they do this using preview, and call system print by browser.

WTF

Our client make a decision, when they click “print” button, there is no preview and other, just print it directly, and, we have to make it as a B/S arch. Therefore, I can only use IE to call dll.

At this moment, our leader tell me: there’s no problem, this framework support IE perfectly.

WTF x2

Yep, just like your think, it’s hardly to find a modern framework that support IE. I can just change my Implementation, run a server on local machine, there have some algorithm to calculate height, it’s annoying to rewrite, so I use a shortcut : all calculation use js on browser but just output printer commands, then local server can forward it to printer.

Problem Raised

It looks like the printer dll provided method have decode Unicode Character as GBK, so we have to convert the coding before send it to printer.

Solution

iconv, a library to convert between codings, this time we convert ‘UTF-8’ to ‘GBK’.

How to connect MySQL Server in wampserver

Open port will cause a security issue, so do that ONLY for dev or debug

I trust we all know that we should set an account for remote access in MySQL, such as


grant all on example_db.* on "example_user"@"%" identified by "your password";
flush privileges;

So, the reason is not misconfig of MySQL, it’s windows firewall, we have to open port by follow actions.

Search(win+Q)->Firewall-> Windows Defender Firewall-> inbound rule

create rule -> port -> release 3306 (sorry I don’t know what is it in English version)