First of all, the source code http://www.codeproject.com/Articles/20574/Open-Source-QRCode-Library of C # qrcode
Then you need to modify someCodeUsed to support Chinese Characters
You may encounter problems when modifying the code.
Question 1 (I have encountered this problem ):
When debugging the winform platform, the following error occurs: 'thoughtworks. qrcode. properties. resources' 'does not contain a definition for 'getresource '.
Change the error location to memorystream = new memorystream (byte []) resources. ResourceManager. GetObject (filename ));
You can.
Question 2:
Example of debugging WmProgramIn encode, an exception occurs when indexoutofrangeexception in rstemp exceeds the maximum index value. The exception is thrown in rstemp [rsblocknumber] [J] = codewords [I2 ~
I thought it was a program logic error. After comparing the desktop and WM class libraries, I found that there was no error. Then I finally found a stupid solution:
I noticed that in the qrcodeencoder. CS class under the qrcodecancelib project,:
Internal static string data_path = "qrcode_data ";
This line of code has been commented out on the desktop version. I guess I want to copy the resource file to this directory of the WM program? Well, create a new folder named qrcode_data under the qrcodewindowsmobile5 project, and then copy the resource files to this directory.
Set the generation action of these resource files to (Copy copy, content), and then re-debug, encode ~ Pass!
Supported Chinese characters for modification:
Modify qrcodeencoder. Cs in the qrcodelib Library
Public Virtual bitmap encode (string content) {If (qrcodeutility. isunicode (content) {return encode (content, encoding. unicode);} else {return encode (content, encoding. ASCII );}}
Is
Public Virtual bitmap encode (string content) {If (qrcodeutility. isunicode (content) {return encode (content, encoding. getencoding ("gb2312");} else {return encode (content, encoding. ASCII );}}
The corresponding code in the qrcodedecoder. CS class also needs to be modified. In this way, both Chinese and English are supported.
Extension
1. Modify qrcodeencoder. CS and qrcodedecoder. CS
Search and convert encoding. Unicode to encoding. utf8.
2. Modify qrcodeutility. CS
Set unicodeencoding encoding = new unicodeencoding ();
Changed to utf8encoding encoding = new utf8encoding ();