BytesToString conversion issue

Description

The function BytesToString() does not convert correctly binary array to FString.
It returns the expected value incremented by one. (In this example case char B is returned instead of A)

A ticket was previously created but it was closed as “Won’t Fix”.
Links to previous tickets:

UTF-16 characters return incorrectly from StringToBytes/BytesToString conversion

StringToBytes/BytesToString broken for some characters

Steps to reproduce

  1. Open UE4 Editor

  2. Add the following code to project anywhere it can be called:

      uint8 test[] = { 0b01000001 }; //binary ASCII code representing char A
    FString conv = BytesToString(test, 1); //conversion resulting as char B
    
    UE_LOG(LogTemp, Warning, TEXT("Test: %s"), *conv); //it will print B instead of A
    
  3. Compile

  4. Run and check the message log

Result:
“Test: B” is printed

Expected:
“Test: A” should be printed

1 Like

I found this bug too.

Yeah it’s really a bummer that this bug is marked as “won’t fix”. Pretty much everyone is stuck writing their own binary-to-strings or hacking the BinaryToString() function with a -1.

1 Like