Glib::ustring::iterator not iterating over chinese character



Hi all,

I'm learning how to use Glib::ustring. My goal is to split an ustring of unicode character into a vector container. In a simple case, my program have read a Chinese character, for example, "你". When I tried to use the Glib::ustring::iterator to go over the ustring, it shows there are more than one entry.

If description = "你", then

        std::cout << "size <" << description.size() << "> ";               
        std::cout << "bytes <" << description.bytes() << "> ";             
        for (Glib::ustring::iterator it = description.begin();            
             it != description.end();                                       
             ++it)                                                          
        {                                                                   
          std::cout << "char <" << (*it) << "> ";                         
        }     

Gives me
size <5> bytes <8> char <228> char <189> char <160> char <10> char <10>

Can someone please explain why the iterator doesn't go over the unicode characters as expected?

Thanks a lot in advance!
weimin


What can you do with the new Windows Live? Find out


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