0

文本编码相关代码:

const char* toCode128C( const char* texto ) {

    int tamanhoTexto = strlen( texto );
    int tamanhoComando = strlen( "{C" ) + tamanhoTexto;

    char* printerCodBarras = new char[ tamanhoComando ];
    memcpy( printerCodBarras, "{C", tamanhoComando );

    for ( int i = 0; i < tamanhoTexto; i += 2 )  {
        int num = QString( texto ).mid( i, 2 ).toInt();
        QString vl = QString( static_cast<char>( num ) );

        strncat( printerCodBarras, vl.toStdString().c_str(), 1 );
    }

    return printerCodBarras;

}

编码成功,除非它包含一个“00”,例如代码59900001,从两个字符转换为两个字符,或者在编码值“00”时出错,从而使(00)不打印。

4

0 回答 0