Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

AnsiString equivalent in qt



  • Hi All

    I am re-writing some old C++ Builder code into Qt, and have come across a variable type:

    AnsiString m_name;
    

    From what I gather it is a form of 'long string', can anyone help me out with what the equivalent is in Qt?

    Thanks

    J



  • @James-Sprinks could you provide some more context about how this variable is used, i.e. what values is assigned, how is employed in your code?



  • If you are referring to this class then QString works and uses UTF8. If you rely on the fact that it will use the system encoding method then restrict interations with it to use QTextStream.


  • Lifetime Qt Champion

    Hi
    QString will do anything you are used to AnsiString does. ( it seems so far)
    The only surprise is that
    int val=10;
    QString test ="val = " + val;
    Does NOT give you "Val =10" as AnsiString would.
    In Qt that is
    QString test ="val = " + QString::number(val);


Log in to reply