到上面的 char16_t 数组
有没有什么办法可以做得很好呢。当我尝试使用Boost的to_upper()
时,我得到一个std::bad_cast
,所以我以这样的结果结束:
while(str[i]!=u'\0')
{
str[i]=(char16_t)to_upper((wchar_t)str[i]);
i++;
}
我什至不确定这是正确的因为我不知道是否能保证char16_t
的to_upper
与原始字符的大小相同。我不确定这是否会导致覆盖下一个字符或再次读取最后一个进动的后半部分。抱歉我提出了愚蠢的问题,但是当涉及到随机访问和具有可变长度编码的字符类型时,我遇到了问题。
Is there any way to do it nicely. When I try to use Boost's to_upper()
, I get a std::bad_cast
, so I ended with something like this:
while(str[i]!=u'\0')
{
str[i]=(char16_t)to_upper((wchar_t)str[i]);
i++;
}
I'm not even sure that this is correct because I don't know if it is guaranteed that to_upper
of char16_t
has the same size as the original character. And I'm not sure if that would cause overwriting of the next character or reading again the second half of the last one precessed. Sorry for my stupid questions, but I have problems when it comes to random access and char types that have variable-length encodings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好的方法可能是这样的:
The best way to do it is probably something like this: