I have a C # project. It is necessary to add the ability to generate qr-codes from the entered text. I downloaded from the Internet and tried various libraries (BarcodeLib.Barcode.WinForms.dll, KeepAutomation.Barcode.Windows.dll, MessagingToolkit.QRCode.dll, OnBarcode.Barcode.WinForms.dll, QRCEEncodeNET.dll, zxing.dll). For some reason, none of them works correctly with the Russian text. I can not understand, these libraries are not designed for the Russian language, or am I doing something wrong? Can anyone come across, tell me pliz solutions.
- As a result, I use the following code from the ZXing library (ICE is taken as the basis): Dictionary <EncodeHintType, object> opt = new Dictionary <EncodeHintType, object> (); opt.Add (EncodeHintType.CHARACTER_SET, "windows-1251"); QRCodeWriter qrCodeWriter = new QRCWWriter (); BitMatrix bm = qrCodeWriter.encode ("my text", BarcodeFormat.QR_CODE, 300, 300, opt); BarcodeWriter barcodeWriter = new BarcodeWriter (); barcodeWriter.Write (bm). Save ("c: \\ 1251.jpeg", ImageFormat.Jpeg); - TabakovAleksey
- This is the answer? If so, it is better to issue it as an answer. - Vlad
|
3 answers
1) Take ZXing
2) Add to the code:
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(); hints.put(EncodeHintType.CHARACTER_SET, "windows-1251"); MatrixToImageWriter.toBufferedImage(new QRCodeWriter().encode("кириллица тут", BarcodeFormat.QR_CODE, 400, 400, hints);
- Sorry, I made a mistake in the first post, zxing did not check it before. Added a link to it in the project. My code does not define the Map, HashMap and MatrixToImageWriter classes. Where to get, tell me pliz. - TabakovAleksey
|
I did this:
ZXing.QrCode.QrCodeEncodingOptions opt = new ZXing.QrCode.QrCodeEncodingOptions { CharacterSet = "utf-8", Height = 200, Width = 200 }; IBarcodeWriter writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE, Options = opt };
|
Why not be easier? Google Chart API
- I do not have a web application, but a winform. And on the computers of users, there is often no connection to the Internet. - TabakovAleksey
- @TabakovAleksey, in this case there is no difference what type of application. But about connecting to an Internet - yes. But such things should be indicated in the question :) - Max Zhukov
|