[Ecls-list] unicode troubles

Polos Ruetz polos.ruetz at gmail.com
Sun Jul 22 22:35:21 UTC 2012


2012/7/22, Арсений Заостровных <necto.ne at gmail.com>:
>     std::string outStr     = (char*)princed->base_string.

This code is taken from "EQL" and converts from/to a QString.
(But maybe there's a better way.)

cl_object from_qstring(const QString& s)
{
    cl_object l_s = ecl_alloc_simple_extended_string(s.length());
    ecl_character* l_p = l_s->string.self;
    for(int i = 0; i < s.length(); ++i) {
        l_p[i] = s.at(i).unicode();
    }
    return l_s;
}


QString toQString(cl_object l_str)
{
    QString s;
    if(ECL_STRINGP(l_str)) {
        if(ECL_BASE_STRING_P(l_str)) {
            s = QString::fromLatin1((char*)l_str->base_string.self,
l_str->base_string.fillp);
        }
        else {
            uint l = l_str->string.fillp;
            s.reserve(l);
            ecl_character* l_s = l_str->string.self;
            for(uint i = 0; i < l; ++i) {
                s[i] = QChar(l_s[i]);
            }
        }
    }
    return s;
}




More information about the ecl-devel mailing list