How to convert String toUpper/toLower Case (Unicode is a MUST; Cyrillic, Greek, etc.)?

a 夏天 提交于 2019-12-23 05:18:29

问题


I'm searching a long time to find a method to convert a NON-LATIN String to upper and/or lowewr case. Cyrillic-, Greek- and co. Writing Systems. So in other words: Convert all characters that support upper/lower case to upper or lower.

NOTE: QString from the Qt Framework supports this feature. But I'm searching for a non-Qt solution.

I tried this piece of code, and it only supports Basic-Latin (a-z, A-Z) neither Á â ş Ş ȧ Ȧ etc. are supported. (???) Why so minimalistic?

#include <iostream>
#include <string>
#include <algorithm>

#include <boost/algorithm/string.hpp>

using std::cout;
using std::cerr;
using std::endl;
using std::cin;
typedef std::string string;

static string text;

int main(void)
{
  cout << "Enter String: ";
  cin >> text;

  for (size_t i = 0; i < text.length(); i++)
    text[i] = std::toupper(text.at(i));

  cout << "Upper Case (libstdc++): " << text << endl;
  cout << "Upper Case (libboost):  " << boost::to_upper_copy(text) << endl;
}

I downloaded the Qt Source Code, but for me as hobby developer I'm unable to find the QString implementations to see whats going on here. And why it supports just ALL.

Is there probably a std or boost way to convert toupper or tolower all these characters that supports it?

A 3th-party library would be ok too.

PS: Sorry for my English.

来源:https://stackoverflow.com/questions/19657894/how-to-convert-string-toupper-tolower-case-unicode-is-a-must-cyrillic-greek

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!