Chinese garbled solution for IPhone Zbar Library--Recompile LIBZBAR.A

Source: Internet
Author: User

Zbar has a problem, for the Chinese two-dimensional code support often appear garbled. Zbar default Support Shif-jis, UTF-8, iso8859-1, but do not support GB18030, and many of the generated two-dimensional code is GB18030 (or GBK, GB2312), so the Zbar decoded out of the direct garbled


This change is actually very simple, only need to modify a file on it, see the following code.


Zbar/qrcode/qrdectxt.c objective-c

int Qr_code_data_list_extract_text (const qr_code_data_list *_qrlist,                                      zbar_image_scanner_t *ISCN,                                      zbar_image_t *img) {   iconv_t                SJIS_CD;    iconv_t               UTF8_CD ;    iconv_t               latin1_ cd;    Const qr_code_data   *qrdata;    int                    Nqrdata;    unsigned char        *mark;    int                     ntext;    int                     i;    qrdata = _qrlist-> qrdata;    nqrdata = _qrlist-> nqrdata;    mark = (unsigned char *) calloc (nqrdata, sizeof (*mark));    ntext = 0;   /*this is the encoding of the standard says is the default.*///focus here, let's not iso8859-1, just change to GB18030.  &N Bsp Latin1_cd=iconv_open ("UTF-8", "iso8859-1");Latin1_cd=iconv_open ("UTF-8", "GB18030");/*but This one is often used, as well.*/SJIS_CD = Iconv_open ("UTF-8", "Sjis"); /*this is trivial conversion just to check validity without extra code.*/utf8_cd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.