Re: help using Glib::ustring



Jamiil Abduqadir wrote:
I am porting my old code to Gtkmm, I have started with the most fundamental of applications, a string manipulation class. What I am trying to do is very simple, but the new paradigm has me a bit confused, to convert a string to upper case here is my code

const Glib::ustring& jme::strtools::toUpper( const Glib::ustring& s ) {
    //global variable
    tmp.clear();
    tmp = s;
    //remove non-printable characters
    tmp = this->trimIt( tmp );
    //Iterate through the string until the end of the is found
    for ( Glib::ustring::iterator i = tmp.begin(); i != tmp.end(); ++i ) {
        *i = toupper( i ); <<=== the old version
    }
    return tmp;
}
i = i.uppercase()  ?? did not work
any suggestions?

If you're writing a string manipulation class (maybe to "flex" your programming muscles?), why use classes that already have "string" functionality such as Glib::ustring? On the other hand, you could use your "s" variable above the following way to convert the string to uppercase: "Glib::ustring upper = s.uppercase()".

-Jose


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]