Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 ustring 对象 sourceString,它是 πøˆ∑´®。我在解析 XML 文件时从 XML 文件中获取这些字符串。我使用 substr 方法来获取这些字符串,如下所示。
Glib::ustring uString = sourceString.substr(5,0);
但是,我只能得到空字符串,我应该如何从中获得子字符串。
不确定substr()在您的情况下是如何实现的,但是我冒险您的参数顺序是错误的!std::string::substr()先占位置,再占大小。在您的情况下,大小为 0。
substr()
std::string::substr()