FString Join without separator


I have a TArray and I want to get the FString that is the concatenation of every item in the array. I know there is a FString::Join function but it require a separator char. I tried with \0 or an empty string but it didn’t work.

Any tips?


I try to be more clear. :slight_smile: Suppose that my array contains { "Q", "W", "Q"}. I’d want to get the string "QWQ" using the Join function without any separator char. Unfortunately I cannot find a “separator” argument to get this result. If I put in the “separator” field an empty string '' or "" the code does not compile.

Note that I have solved the basic problem with an handmade loop, but I’d like to know if it is possible using the standard join function.

I don’t really understand. The separator char is just used to be inserted in between two FString from your array.

For instance, if you have “Hello” as first entry, and “World” and second, if you provide an empty space as separator, Join should return “Hello World”.

Could you describe what’s going wrong ?

What if you provide NULL as separator ?

Hi! I edited the question with additional info. In short: I want an empty separator between my strings.

Just tried. With NULL or \0 the editor crashes.

Okay. It’s a TCHAR, so, maybe _T(’\0’) ?

Crash again. I also tried with _T(''). This time compile… but the editor crashes again. Maybe it is just a “feature” of the Join function to not accept an empty separator. :slight_smile:

Yeah, but I looked at the code of the Join function, and it’s pretty simple… That really should work actually…

I just tried, it work for me… Maybe it’s in your code ? One of your FString in the array could be NULL ? Or something ?


With this code :

TArray<FString> arrayOfString;

FString result = FString::Join(arrayOfString, _T(''));

Yes. It is strange because my test example is not more complicated than yours. The only difference is that my function is a blueprintable-pure function that returns the Join’s result. And I use this function inside the Level Blueprint. Moreover, if I substitute the Join implementation code inside my function, it works. :expressionless:

I try with an empty project. Maybe there is something I messed up.

(this is the crash stacktrace if somebody want to see it: !Id:9630bf454cc94ad8453ac83491bffbefAccess violation - code c0000005 (first/ - Pastebin.com)

FString::Join is a static function, and takes a TCHAR* as the separator.

I would have expected the following code to work correctly:

FString Result = FString::Join(Array, TEXT(""));

as the StrLen inside:

FString& operator+=( const TCHAR* Str )

Will be zero, resulting in no appending for the separator

Yes, strange. As I see you’ve got an access violation, so I would more try to see in the construction of you TArray. Just a guess.