小编Qma*_*man的帖子

C++中的UTF-8兼容性

我正在编写一个程序,需要能够使用所有语言的文本.我的理解是UTF-8将完成这项工作,但我遇到了一些问题.

我是否可以说UTF-8可以存储char在C++中?如果是这样,为什么我在使用程序时会收到以下警告char,string并且stringstream:warning C4566: character represented by universal-character-name '\uFFFD' cannot be represented in the current code page (1252).(我使用时没有出现错误wchar_t,wstring并且wstringstream.)

另外,我知道UTF是可变长度的.当我使用atsubstr字符串方法时,我会得到错误的答案?

c++ unicode wchar-t utf-8 wstring

11
推荐指数
2
解决办法
1万
查看次数

Boost的Dijkstra算法教程

我很难弄清楚如何使用Boost的Dijkstra算法.我已经查看了他们的示例和文档,但我仍然无法理解如何使用它.

[增强的文档:http://www.boost.org/doc/libs/1_50_0/libs/graph/doc/dijkstra_shortest_paths.html] [迪杰斯特拉的实施例:http://www.boost.org/doc/libs/1_36_0 /libs/graph/example/dijkstra-example.cpp]

有人可以用代码示例提供一步一步的解释,以展示如何使用Boost的Dijkstra算法吗?我正在使用Boost的adjacency_list作为我的图表,就像上面的示例链接一样.(adjacency_list:http://www.boost.org/doc/libs/1_50_0/libs/graph/doc/adjacency_list.html)

c++ boost dijkstra visual-c++

7
推荐指数
1
解决办法
7065
查看次数

UTF-8字符串迭代器

我正在尝试编写支持Unicode的跨平台应用程序.我正在使用库UTF8-C++(http://utfcpp.sourceforge.net/)但我在迭代字符串时遇到问题:

string s1 = "?????? ????";
utf8::iterator<string::iterator> iter(s1.begin(), s1.begin(), s1.end());

for(int i = 0; i < utf8::distance(s1.begin(), s1.end()); i++, ++iter)
{
    cout << (*iter);
}
Run Code Online (Sandbox Code Playgroud)

上面的代码重定向到UTF-8格式的文本文件时,会产生以下输出:

6 3 6 3 6 3 6 3 6 3 6 3 3 2 6 3 6 3 6 3 6 3 
Run Code Online (Sandbox Code Playgroud)

如何才能s1正确显示文件中的内容?

c++ string unicode iterator utf-8

6
推荐指数
2
解决办法
4147
查看次数

ptr_vector未正确释放

我试图使用ptr_vector来存储一些指针,但是我的main方法一出现就出错了.这是我的代码:

int main(void)
{
    boost::ptr_vector<string> temp;
    string s1 = "hi";
    string s2 = "hello";
    temp.push_back(&s1);
    temp.push_back(&s2);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误消息:

Critical error detected c0000374
Windows has triggered a breakpoint in Path_Tree.exe.

This may be due to a corruption of the heap, which indicates a bug in Path_Tree.exe or     any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Path_Tree.exe has focus.

The output window may have more diagnostic information.
The program '[7344] …
Run Code Online (Sandbox Code Playgroud)

c++ boost ptr-vector boost-ptr-container

1
推荐指数
1
解决办法
446
查看次数