fix non-Codecvt build

This commit is contained in:
Syping 2021-10-12 01:03:17 +02:00
parent cfc0af179f
commit 8ea05274f0
2 changed files with 3 additions and 1 deletions

View file

@ -451,6 +451,8 @@ bool RagePhoto::save(char *data, PhotoFormat photoFormat)
char photoHeader[256]; char photoHeader[256];
memcpy(photoHeader, photoString.data(), photoString_size); memcpy(photoHeader, photoString.data(), photoString_size);
#else #else
const size_t photoString_size = 0;
char photoHeader[256];
std::cout << "UTF-16LE encoding support missing" << std::endl; std::cout << "UTF-16LE encoding support missing" << std::endl;
p_error = Error::UnicodeInitError; // 4 p_error = Error::UnicodeInitError; // 4
return false; return false;

View file

@ -57,7 +57,7 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}; };
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert; std::wstring_convert<std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::little_endian>,char16_t> convert;
std::string photoString = convert.to_bytes(reinterpret_cast<char16_t*>(photoHeader)); std::string photoString = convert.to_bytes(reinterpret_cast<char16_t*>(photoHeader));
return strcmp(photoString.c_str(), "PHOTO - 02/01/17 08:42:44"); return strcmp(photoString.c_str(), "PHOTO - 02/01/17 08:42:44");
} }