Chinese character issues displayed in qt



  • Hi all,,

          I am using ubuntu14.04,,if i pass the chines character in button menas it displayed correct chinese character,,,and if i pass the chinese character in printer means in the receipt page chinese characters are not displayed properly,,Question mark characters are appeared in the receipt instead of chinese character,,Please give me some suggesstion,,Thanks,,,



  • Moderators

    Hi,

    Please show your code.

    What encoding do you use? How do you pass your string to the printer?



  • Hi friends,

               @    @QString ItemPushButton::name_check(QString str)
    

    {
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QRegExp [removed]"#([0-9]+);");
    QStringList list,list1;
    int pos = 0;
    int length;
    while((pos = expression.indexIn(str,pos))!=-1)
    {
    list << expression.cap(1);
    QString v;
    length = expression.matchedLength();
    v=str.mid(pos+1,length-1-1);
    QByteArray ba = v.toUtf8();
    QString str1 = QString(QChar(v.toInt()));
    list1 <<str1;
    pos += expression.matchedLength();
    }
    foreach (QString s, list) {
    str.replace(s,"");
    }
    str = str.replace("#","");
    str = str.replace(";","");

    foreach (QString s, list1) {
        str = str.append(s);
    }
    return str;
    

    }@

    This is my code,,In here i get the chinese character string,,, after that i pass this string to printer directly,,,In the receipt page other characters are comes correctly,,,the chinese character only the problem,,It prints the Question mark instead of chinese character,,Please give me a suggesstion,,,Thanks,


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.