-
Notifications
You must be signed in to change notification settings - Fork 177
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
Platform agnostic string types #566
Comments
Just noting that doing this will make
I don't think it's appropriate to replace These are the three original reasons why
|
Regarding 4, CC and Arch seemed to have different thoughts on how often to use StringType vs FString than you and I did. I'd like them to chime in. |
yeah.. although I'm not sure how to ... but another way is to time slice the program to use u16stirng at the beginning and switch to (somehow) fully FString later.. it might make the typing hard to manage somehow.. |
I think ideally our setup would end up being very similar to Unreal's with Unreal's core source being the earliest dependency. So it makes sense to typedef it there so it propagates up. |
So my idea was to use basic_string before we get unreal allocator, and FString after, for functions which need to work with both we just make them templated to support both. This presented an issue that FString is not as nice to work with and ofc no external library will support it. So the end solution is we use both strings, FString at unreal boundary and basic_string everywhere else, we of course need to write conversion functions between the two, but it will mostly be no-ops at runtime so won't cause performance concerns. |
So.. solve the circluar deps seem extra works and not related to this.. will create a string module and use macro to define which char type to use.. |
https://github.com/Yangff/RE-UE4SS/tree/port/strings-fmt This branch should contain attempt to use Currently I'm able to compile it without UVTD when setting CharType = char16_t, this should contain most typing work reuqired for Linux port. Real windows build should use wstring which should compile without any problem because no type are changed. UVTD is excluded from this because it's Windows only. |
Okay, getting the PRs in. Related PRs are: FmtLib #565 |
The current implementation of UE4SS uses
File::StringType = std::wstring
andwchar_t
as the primary character types, assuming compatibility with Unreal's main character typeTCHAR
, and uses UTF-16 encoding. Additionally, UE4SS uses this type as the working type for the platform file system. The following issues have been observed:std::wstring
iswchar_t
, whosesizeof
is 4, using UTF-32 instead of UTF-16.std::u16string
has compatibility issues with existing C++ STL, such as not being accepted bystd::format
. On the Linux platform, neitherwstring
noru16string
is directly accepted by Linux or the C standard library. On Windows, althoughwchar_t
andchar16_t
are essentially the same, they cannot be implicitly converted, and usingu16string
introduces potential issues.char16_t
should be used.Therefore, the following changes are planned (please make modifications):
std::basic_string<TCHAR>
as part of Unreal, no longer belonging to the File namespace.u16string
to providestd::format
.u16string
on Windows. This approach has the benefit of triggering errors on Windows if they directly access the underlying type ofu16string
without appropriate conversion/encoding, thereby exposing potential issues.Please comment/update here and make sure we agree on what changes go into the strings PR etc..
The text was updated successfully, but these errors were encountered: