Remove old workaround for MinGW's lack of unicode support

Dates back to 2009 when 78247bd38 was written. I'm going to assume
the situation has improved in the last 14 years. There are SFML
users who weren't even alive in 2009...
This commit is contained in:
Chris Thrasher 2023-03-28 21:48:20 -06:00
parent 06c5c50537
commit 14dbd3c899

View File

@ -657,28 +657,11 @@ Out Utf<32>::toUtf32(In begin, In end, Out output)
template <typename In> template <typename In>
std::uint32_t Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale) std::uint32_t Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale)
{ {
// On Windows, GCC's standard library (glibc++) has almost
// no support for Unicode stuff. As a consequence, in this
// context we can only use the default locale and ignore
// the one passed as parameter.
#if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \
(defined(__GLIBCPP__) || defined(__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
!(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
wchar_t character = 0;
mbtowc(&character, &input, 1);
return static_cast<std::uint32_t>(character);
#else
// Get the facet of the locale which deals with character conversion // Get the facet of the locale which deals with character conversion
const auto& facet = std::use_facet<std::ctype<wchar_t>>(locale); const auto& facet = std::use_facet<std::ctype<wchar_t>>(locale);
// Use the facet to convert each character of the input string // Use the facet to convert each character of the input string
return static_cast<std::uint32_t>(facet.widen(input)); return static_cast<std::uint32_t>(facet.widen(input));
#endif
} }
@ -700,25 +683,6 @@ std::uint32_t Utf<32>::decodeWide(In input)
template <typename Out> template <typename Out>
Out Utf<32>::encodeAnsi(std::uint32_t codepoint, Out output, char replacement, [[maybe_unused]] const std::locale& locale) Out Utf<32>::encodeAnsi(std::uint32_t codepoint, Out output, char replacement, [[maybe_unused]] const std::locale& locale)
{ {
// On Windows, gcc's standard library (glibc++) has almost
// no support for Unicode stuff. As a consequence, in this
// context we can only use the default locale and ignore
// the one passed as parameter.
#if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \
(defined(__GLIBCPP__) || defined(__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
!(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
char character = 0;
if (wctomb(&character, static_cast<wchar_t>(codepoint)) >= 0)
*output++ = character;
else if (replacement)
*output++ = replacement;
return output;
#else
// Get the facet of the locale which deals with character conversion // Get the facet of the locale which deals with character conversion
const auto& facet = std::use_facet<std::ctype<wchar_t>>(locale); const auto& facet = std::use_facet<std::ctype<wchar_t>>(locale);
@ -726,8 +690,6 @@ Out Utf<32>::encodeAnsi(std::uint32_t codepoint, Out output, char replacement, [
*output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement); *output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);
return output; return output;
#endif
} }