You need to convert the string char*- "multibyte" in ISO C - to the string wchar_t*- "wide character" in ISO C. The standard function that does this is called mbstowcs("Multibyte string for wide character string")
: , C99 , , ISO ++, ++ . MSVC g++ .
:
const char* input = ...;
std::size_t output_size = std::mbstowcs(NULL, input, 0);
std::vector<wchar_t> output_buffer(output_size);
std::mbstowcs(&output_buffer[0], input, output_size);
std::wstring output(&output_buffer[0]);
wstring s, , . , ( Windows ANSI) - , , , , - iconv.
, -, (.. (wchar_t)c char c ). , , , , char - ASCII Latin-1, wchar_t - Unicode. , , - std::lexicographical_compare:
#include <algorithm>
const char* s = ...;
std::wstring ws = ...;
const char* s_end = s + strlen(s);
bool is_ws_less_than_s = std::lexicographical_compare(ws.begin, ws.end(),
s, s_end());
bool is_s_less_than_ws = std::lexicographical_compare(s, s_end(),
ws.begin(), ws.end());
bool is_s_equal_to_ws = !is_ws_less_than_s && !is_s_less_than_ws;
, std::equal :
#include <algorithm>
const char* s = ...;
std::wstring ws = ...;
std::size_t s_len = strlen(s);
bool are_equal =
ws.length() == s_len &&
std::equal(ws.begin(), ws.end(), s);