c++ - boost::filesystem::path 与 boost::filesystem::wpath

标签 c++ boost encoding path

Boost 库有一个类来处理文件路径:boost::filesystem::path。 Boos 也有这个类 boost::filesystem::wpath

每个类都有方法string(), wstring(), c_str(), native()

我开发 Windows 应用程序,我完全不明白我应该使用什么 ))

从实用的角度来看,这两个类有什么区别?这些方法有什么区别?

我应该为 Windows 应用程序使用什么类和什么方法? ::wpathwstring() 无处不在?

部分源代码(几个静态链接库)将为 Ubuntu 编译。在这种情况下 ::wpath 还好吗?


我还使用 SQLite 并且它需要数据库文件的路径。 sqlite3_open .

我应该使用sqlite3_open_v2(文件路径的UTF-8编码)还是sqlite3_open16(文件路径的UTF-16编码)?


附言看完这篇文章link似乎 ::path::wpath 完全没有区别。对吗?

方法native() 似乎更适合为不同平台编译的源代码。

最佳答案

What is the difference between these two classes from the practical point of view? What is the difference between these methods?

What class and what methods should I use for Windows app? ::wpath and wstring() everywhere?

值得一提的是,对于现在的几个版本,Boost 已经弃用了 wpath,而应该使用 class path。参见 Boost Deprecated Features (current release)

“在引擎盖下”,Boost 使用 std::stringstd::wstring 表示 pathwpath code> 其中wstring用于表示宽字符串,即支持更大的字符集。

大部分问题都在这里得到解答:std::wstring VS std::string

Method native() seems preferable for the source code that compiled for different platforms

没错。如果它只是您正在开发的 Windows 应用程序,则可以在 native()

上使用 wstring()

关于c++ - boost::filesystem::path 与 boost::filesystem::wpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35525611/

相关文章:

c++ - 在 Go (golang) 和 C++ 之间交换数据结构(数组)

c++ - for_each 中使用的函数的默认值

c++ - 如何创建简单的带有 boost 的 HTTP 服务器,能够接收数据编辑和共享?

python - Windows 上的 boost python 在导入 ("__main__"时崩溃);

java - Windows 上 JLabel 中的 UTF-8 编码

c++ - 双线性插值伪影

c++ - 继承中的boost库

c++ - boost::condition_variable::notify_one() 的并发性

c# - 生成用户特定的 1 次优惠券代码

c# - 发送一个填充特殊字符的字节数组