Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: QRCode Barcode item cannot handle CJK character  (Read 6436 times)

eqychan

  • Newbie
  • *
  • Posts: 4
    • View Profile
QRCode Barcode item cannot handle CJK character
« on: February 15, 2016, 10:59:56 pm »
LimeReport is perfect! thanks.
QRCode Barcode item cannot handle CJK character, and there is no barcode item in LimeReport::ReportDesignWindow(). would you plan to add it in the next version?

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: QRCode Barcode item cannot handle CJK character
« Reply #1 on: February 16, 2016, 12:00:04 pm »
LimeReport use zint library to support barcodes. You have to turn on zint support in the limereport.pro. Remove comment before CONFIG +=zint and configure zint library.
What about CJK character. According to the documentation zint can use UTF-8 but maybe something wrong between zint and barcode item.
« Last Edit: February 16, 2016, 03:19:57 pm by Arin Alex »

eqychan

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: QRCode Barcode item cannot handle CJK character
« Reply #2 on: February 16, 2016, 04:49:03 pm »
LimeReport use zint library to support barcodes. You have to turn on zint support in the limereport.pro. Remove comment before CONFIG +=zint and configure zint library.
What about CJK character. According to the documentation zint can use UTF-8 but maybe something wrong between zint and barcode item.
thanks for your reply! following your instructions, I resolved the barcode problem. :)
I changed source code in your lrbarcodeitem.cpp to resolve the CJK problem by adding a function to find whether the input string contains CJK character, if true, change barcode input mode to 0, otherwise do nothing. now it works fine!:D

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: QRCode Barcode item cannot handle CJK character
« Reply #3 on: February 16, 2016, 04:56:20 pm »
Could you send you changes to us?

eqychan

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: QRCode Barcode item cannot handle CJK character
« Reply #4 on: February 16, 2016, 05:03:05 pm »
// My Code start ----------------------------------------------------
bool hasCJK(QString qs)
{
    int qslen = qs.length();
    if (qslen == 0)
        return false;
    else if (qslen == qs.toLocal8Bit().length())
        return false;
    return true;
}
// My code end ------------------------------------------------------


void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    ppainter->save();
    Zint::QZint bc;
// Original code Start -----------------------------------------------------------------------
//    if (itemMode() & DesignMode) bc.setText(m_designTestValue);
//    else bc.setText(m_content);
// Original code end -------------------------------------------------------------------------
// My Code Start -----------------------------------------------------------------------------
    QString qs;
    if (itemMode() & DesignMode) qs = m_designTestValue;
    else qs = m_content;
    if (hasCJK(qs))
        bc.setInputMode(0);
    bc.setText(qs);
// My code end --------------------------------------------------------------------------------
    bc.setSymbol(m_barcodeType);
    bc.setWhitespace(m_whitespace);
    bc.setFgColor(m_foregroundColor);
...
...

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: QRCode Barcode item cannot handle CJK character
« Reply #5 on: February 16, 2016, 05:04:36 pm »
Thanks!

eqychan

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: QRCode Barcode item cannot handle CJK character
« Reply #6 on: February 16, 2016, 05:05:49 pm »
I am not professional in coding... sorry ;)