首页 > 解决方案 > 有没有办法在不使用 L 或 u 字符的情况下编写函数参数(wchar_t 或 char16_t)?

问题描述

我有一个函数,其参数为wchar_t*or char16_t*,例如:

void showMsg(char16_t *msg){ // or "wchar_t *msg"
    wcout << msg; 
}

正如我们所知,我们必须在文本之前使用 L 或 u,如下所示:

showMsg(u"おはようございます"); // for char16_t* must use "u"
showMsg(L"おはようございます"); // for wchar_t* must use "L"

有没有不使用Loru字符来编写字符串参数的方法或技巧?

标签: c++

解决方案


推荐阅读