#include <string>#include <algorithm>#include <iostream>
int main (int argc, char* argv[]){std::string sourceString = "Abc";std::string destinationString;
// Allocate the destination spacedestinationString.resize(sourceString.size());
// Convert the source string to lower case// storing the result in destination stringstd::transform(sourceString.begin(),sourceString.end(),destinationString.begin(),::tolower);
// Output the result of the conversionstd::cout << sourceString<< " -> "<< destinationString<< std::endl;}
#include <unicode/unistr.h>#include <unicode/ustream.h>#include <unicode/locid.h>
#include <iostream>
int main(){/* "Odysseus" */char const * someString = u8"ΟΔΥΣΣΕΥΣ";icu::UnicodeString someUString( someString, "UTF-8" );// Setting the locale explicitly here for completeness.// Usually you would use the user-specified system locale,// which *does* make a difference (see ı vs. i above).std::cout << someUString.toLower( "el_GR" ) << "\n";std::cout << someUString.toUpper( "el_GR" ) << "\n";return 0;}
#include <locale>#include <iostream>
int main () {std::locale::global(std::locale("en_US.utf8"));std::wcout.imbue(std::locale());std::wcout << "In US English UTF-8 locale:\n";auto& f = std::use_facet<std::ctype<wchar_t>>(std::locale());std::wstring str = L"HELLo, wORLD!";std::wcout << "Lowercase form of the string '" << str << "' is ";f.tolower(&str[0], &str[0] + str.size());std::wcout << "'" << str << "'\n";}
#include <iostream>#include <string>using namespace std;
int main(){std::string _input = "lowercasetouppercase";#if 0// My idea is to use the ascii value to convertchar upperA = 'A';char lowerA = 'a';
cout << (int)upperA << endl; // ASCII value of 'A' -> 65cout << (int)lowerA << endl; // ASCII value of 'a' -> 97// 97-65 = 32; // Difference of ASCII value of upper and lower a#endif // 0
cout << "Input String = " << _input.c_str() << endl;for (int i = 0; i < _input.length(); ++i){_input[i] -= 32; // To convert lower to upper#if 0_input[i] += 32; // To convert upper to lower#endif // 0}cout << "Output String = " << _input.c_str() << endl;
return 0;}