text_encoding


1. Encoding Text to UTF-8:

#include <string>
#include <locale>

int main() {
  std::wstring wstr = L"Hello, world!";
  std::string str = std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(wstr);
  std::cout << str << std::endl;  // Output: Hello, world!
  return 0;
}

2. Decoding UTF-8 Encoded Text:

#include <string>
#include <locale>

int main() {
  std::string str = "Hello, world!";
  std::wstring wstr = std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(str);
  std::wcout << wstr << std::endl;  // Output: Hello, world!
  return 0;
}

3. Encode Text to Base64:

4. Decode Base64 Encoded Text:

5. Encode Text to Caesar Cipher:

6. Decode Caesar Cipher Encoded Text:

7. Encode Text to MD5 Hash:

8. Encode Text to SHA-256 Hash: