diff --git a/src/SFML/Window/Linux/WindowImplX11.cpp b/src/SFML/Window/Linux/WindowImplX11.cpp index de2eefb2..f2f8ec40 100644 --- a/src/SFML/Window/Linux/WindowImplX11.cpp +++ b/src/SFML/Window/Linux/WindowImplX11.cpp @@ -322,9 +322,9 @@ void WindowImplX11::setTitle(const String& title) // Convert to UTF-8 encoding. std::basic_string utf8Title; - std::wstring wideTitle = title.toWideString(); - sf::Utf8::fromWide(wideTitle.begin(), wideTitle.end(), std::back_inserter(utf8Title)); + sf::Utf32::toUtf8(title.begin(), title.end(), std::back_inserter(utf8Title)); + // Set the _NET_WM_NAME atom, which specifies a UTF-8 encoded window title. Atom wmName = XInternAtom(m_display, "_NET_WM_NAME", False); Atom useUtf8 = XInternAtom(m_display, "UTF8_STRING", False); XChangeProperty(m_display, m_window, wmName, useUtf8, 8, diff --git a/src/SFML/Window/OSX/cpp_objc_conversion.mm b/src/SFML/Window/OSX/cpp_objc_conversion.mm index f8323833..a510fc08 100644 --- a/src/SFML/Window/OSX/cpp_objc_conversion.mm +++ b/src/SFML/Window/OSX/cpp_objc_conversion.mm @@ -28,6 +28,7 @@ //////////////////////////////////////////////////////////// #include +#import #import //////////////////////////////////////////////////////////// @@ -45,7 +46,17 @@ NSString* sfStringToNSString(sf::String const& string) { sf::Uint32 length = string.getSize() * sizeof(sf::Uint32); const void* data = reinterpret_cast(string.getData()); - NSString* str = [[NSString alloc] initWithBytes:data length:length encoding:NSUTF32LittleEndianStringEncoding]; + NSStringEncoding sfEncoding; + if (NSHostByteOrder() == NS_LittleEndian) + { + sfEncoding = NSUTF32LittleEndianStringEncoding; + } + else + { + sfEncoding = NSUTF32BigEndianStringEncoding; + } + + NSString* str = [[NSString alloc] initWithBytes:data length:length encoding:sfEncoding]; return str; }