I use a c++ plugin to write some text to a file and I use the vfprintf function. In a visual studio application the output would be :a|b|c but UnrealEngine writes to file a(!!T#b(!!T#c. Any idea how to solve this ?
Thankyou
It depends on how you generate the text and it’s type but you have provided no code.
I can tell you from now that UE4 has a specific rules for handling strings and files (see FFileHelper). Some of the C++ library functions are not supported along with some data types in order to be cross-platform. (I assume)
Check the documentation if you haven’t.
Hi, thankyou for answering. I used FString Fs = FString(ANSI_TO_TCHAR(arr));
FString Fs = FString(UTF8_TO_TCHAR(arr)); but its the same output so I think there is a problem when it compiles the c code. I think its missing the _MBCS setting which is in the default visual studio project
To directly answer the question: There is a discrepancy between the encoding of your input and your output. A string is useless without it’s encoding information. See: Character Encoding.
As I implied in the comment, you should not use special characters in your text files. Always save strings in the provided types by the engine.
This is already asked in a sort but for Asian characters: https://answers.unrealengine.com/questions/802364/view.html
The answer there is very exhaustive.
I wrote the text like this
`int cst_sprintf(char *s, const char *fmt, …)
{
va_list args;
int rv;
va_start(args, fmt);
rv = vsprintf(s, fmt, args);
va_end(args);
return rv;
}
`
I even tried to send the text through a char array and the output is the same.
I solved this, the encoding was not the problem. I was writing a char instead of a char * to the file.