coder8113 / CFOOD2

0 stars 1 forks source link

std::wstring_convert / std::codecvt is deprecated #16

Open btrifkovic opened 3 months ago

btrifkovic commented 3 months ago

The std::wstring_convert and std::codecvt conversion utilities have been deprecated since C++17 due to inconsistencies in output across standard library implementations. Normally, this is not a burning issue (see: std::strstream) however these utilities have since been removed in the upcoming C++26 standard.

The code below may also be unified into a single string conversion utility: https://github.com/coder8113/CFOOD2/blob/9a3a1e4959bc390b35c60d373275c79df80b2683/src/CFood.cpp#L23-L31 https://github.com/coder8113/CFOOD2/blob/9a3a1e4959bc390b35c60d373275c79df80b2683/src/file.cpp#L142-L146

Since the project seems to only target Windows, I'd recommend using WideCharToMultiByte or RtlUnicodeToUTF8N API for conversion (which also offers counterparts for converting UTF8 to Unicode). Alternatively, you may use libiconv or utfcpp for a cross-platform solution.