It does seem FString doesn’t support the Ö although the documentation under character encoding says it is “Characters between 32 and 126 inclusive” which would include Ö.
Now I am having this issue in both reading file names, displaying them, and saving a list of files to a .txt file so I would much rather be able to use FString to manipulate these with Unreal functions.
I guess you are using Visual Studio for you C++ project, right? So you can debug in there. Unreal comes with a source code so when you debug your code, you can go inside Engine’s source code.
10 bytes for both FString and char and FileHandle->Write and FFileHelper::SaveStringToFile. I found I can get the character to display correctly with FileHandle->Write and char although it’s not ideal (updated original post).
ok, this is what happening: you save as ASCII file, not as Unicode. That is why you see ‘?’. Unicode is 2 bytes per character. If you save in UTF8, then Ö should be converted into \x00D6. In Windows, do you have set up your language as local? Like in mine, all Russian letters will go as ASCII, not Unicode.
Huh, I’m probably not using Unicode however I am still a bit confused.
When I create a .txt file in windows I can use the Ö character and also that character falls under the ASCII range of between 32 and 126 (and is only 1 byte per character).
What I’m basically trying to do is allow users to select music on their computer so allow whatever is allowed in windows file names. I tested with my file and came across “Röyksopp” which is where this whole issue started.
Thanks. I found that article too which says "All strings in Unreal Engine 4 (UE4) are stored in memory in UTF-16 " and as my edited post it seems to have an issue with FString and FileHandle->Write but not char.
It is part of extended ASCII table, codes > 127. It highly depends on a codepage what is there. For example, I have Russian alphabet there. So, any Russian text will be saved as 1 byte character. Anyway, I see where the problem is. I’ll try myself like in your example to save it. It will be good to know anyway.
Ok, I made it to save into Unicode:
FString newText = “AAAA\x00D6 BBBB”;
FFileHelper::SaveStringToFile(newText, TEXT(“C:/test.txt”), FFileHelper::EEncodingOptions::ForceUnicode);
File size is 22 bytes.
BUT, looking through a debugger, “AAAA\x00D6 BBBB” gets converted in FString to “AAAA? BBBB”. So, the problem is not actually in SaveStringToFile, but what you are saving.
The correct way: FString newText = TEXT(“AAAA\x00D6 BBBB”);