Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using unicode characters in world names regardless of system language on Windows 10 1903 and newer versions #51475

Merged
merged 1 commit into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,8 @@ $(ODIR)/%.o: $(SRC_DIR)/%.cpp $(PCH_P)
$(ODIR)/%.o: $(SRC_DIR)/%.rc
$(RC) $(RFLAGS) $< -o $@

$(ODIR)/resource.o: data/cataicon.ico data/application_manifest.xml

src/version.h: version

src/version.cpp: src/version.h
Expand Down
21 changes: 21 additions & 0 deletions data/application_manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" name="com.cleverraven.cataclysmdda" version="0.0.0.0"/>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">
<activeCodePage>UTF-8</activeCodePage>
</asmv3:windowsSettings>
</asmv3:application>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp)
set(MESSAGES_CPP ${CMAKE_SOURCE_DIR}/src/messages.cpp)
set(RESOURCE_RC ${CMAKE_SOURCE_DIR}/src/resource.rc)

if (WIN32)
set(RSRC_RC_DEP "${CMAKE_SOURCE_DIR}/data/cataicon.ico")
set(RSRC_RC_DEP "${RSRC_RC_DEP};${CMAKE_SOURCE_DIR}/data/application_manifest.xml")
set_source_files_properties(
${RESOURCE_RC}
PROPERTIES
OBJECT_DEPENDS "${RSRC_RC_DEP}")
endif ()

file(GLOB CATACLYSM_DDA_SOURCES ${CMAKE_SOURCE_DIR}/src/*.cpp)

list(REMOVE_ITEM CATACLYSM_DDA_SOURCES ${MAIN_CPP} ${MESSAGES_CPP})
Expand Down
22 changes: 22 additions & 0 deletions src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,25 @@ std::string ensure_valid_file_name( const std::string &file_name )

return new_file_name;
}

#if defined(_WIN32) && defined(__GLIBCXX__)
// GLIBCXX does not offer the wchar_t extension for fstream paths
std::string cata::_details::path_to_native( const fs::path &p )
{
if( GetACP() == 65001 ) { // utf-8 code page
return p.u8string();
} else {
return wstr_to_native( p.wstring() );
}
}
#elif defined(_WIN32)
std::wstring cata::_details::path_to_native( const fs::path &p )
{
return p.wstring();
}
#else
std::string cata::_details::path_to_native( const fs::path &p )
{
return p.u8string();
}
#endif
18 changes: 3 additions & 15 deletions src/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,10 @@ namespace cata
{
namespace _details
{
#if defined(_WIN32) && defined(__GLIBCXX__)
// GLIBCXX does not offer the wchar_t extension for fstream paths
inline std::string path_to_native( const fs::path &p )
{
return wstr_to_native( p.wstring() );
}
#elif defined(_WIN32)
inline std::wstring path_to_native( const fs::path &p )
{
return p.wstring();
}
#if defined(_WIN32) && !defined(__GLIBCXX__)
std::wstring path_to_native( const fs::path &p );
#else
inline std::string path_to_native( const fs::path &p )
{
return p.string();
}
std::string path_to_native( const fs::path &p );
#endif
} // namespace _details

Expand Down
2 changes: 2 additions & 0 deletions src/resource.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RESOURCE_RC_INCLUDED
#define RESOURCE_RC_INCLUDED

#include <windows.h>
0 ICON "../data/cataicon.ico"
1 RT_MANIFEST "../data/application_manifest.xml"

#endif // RESOURCE_RC_INCLUDED