如何将 unicode 字符放入文件名中? 我有一个 ostringstream,用于通过 ofstream 定义文件名,但我不能使用 unicode 字符。这样做最简单的方法是什么?以 unicode 格式重命名它?并请解释我将如何这样做。
最佳答案
你的问题不清楚。如果你想放置 unicode 字符——STL 中的任何字符串/流类都有它的 unicode 等价物。 std::string/std::wstring,std::stringstream/std::wstringstream。如果您使用 std::wstringstream,请在此处将 unicode 字符放入其中:
std::wstringstream wideStream;
wideStream << L"Hello, world";
std::wstring wideString = wideStream.str();
希望这对您有所帮助。
关于c++ - 使用 Unicode 重命名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23210741/