Skip to content

Commit

Permalink
Remove old workaround for MinGW's lack of unicode support
Browse files Browse the repository at this point in the history
Dates back to 2009 when 78247bd 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...
  • Loading branch information
ChrisThrasher committed Apr 4, 2023
1 parent 06c5c50 commit 14dbd3c
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions include/SFML/System/Utf.inl
Original file line number Diff line number Diff line change
Expand Up @@ -657,28 +657,11 @@ Out Utf<32>::toUtf32(In begin, In end, Out output)
template <typename In>
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
const auto& facet = std::use_facet<std::ctype<wchar_t>>(locale);

// Use the facet to convert each character of the input string
return static_cast<std::uint32_t>(facet.widen(input));

#endif
}


Expand All @@ -700,34 +683,13 @@ std::uint32_t Utf<32>::decodeWide(In input)
template <typename Out>
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
const auto& facet = std::use_facet<std::ctype<wchar_t>>(locale);

// Use the facet to convert each character of the input string
*output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);

return output;

#endif
}


Expand Down

0 comments on commit 14dbd3c

Please sign in to comment.