Text vs String variable

I am working on a multiplayer chat system, and when the player types a message containing more than around 1000 characters, it disconnects them from the session. I am currently using and transferring text variables over the network, but am wondering if it would be more efficient to use string variables for such large pieces of text. What are the differences between the two variable types?

In blueprints a text varaible will be slightly and I mean slighlty more effecient overall since its what the widget classes use. But thats just a guess.

From a code point of view, which your blueprints end up anyway, and in a network setting especially, strings are FAR more effecient.

In c++ strings would be more effecient since they are well optomized in the UE4 API.

FText is 40 bytes ~ (more than 2x size
of FString, more than 4x the size of
an FName)

FString is 16 bytes ~ (2x size of
FName, 4x the size of a float/int32)

FName is 8 bytes ~ (smallest! Twice
the size of a float/int32)

So whenever you dont need the extra
bytes you can use FName, and you
should only use FText for visible
displayed text that actually matters
to be different, region to region,
thus requiring Localization.

Your internal naming scheme in code
can be be FString or FName

Advantage of FString is all the handy
functions in UnrealString.h

FString is the easiest type to
manipulate, modify, search and
replace, concatenate, etc etc.

Strings you save to hard disk or send
over the network should be FName to
minimize data storage / data transfer

Remember, with FName you are sending
half the bytes across the network but
you can still reconstruct into an
FString on the other side!

I’m not a staff member but a staff mebmer ddi have this to say

FNames are usually going to be an ID
for something. They’re
case-insensitive, which is probably
the most important thing to remember
about them.

Asset names

Material Parameters

Tagging Actors

Skeleton bone names

FText is generally what you want to
use for anything that your users will
see, even if you aren’t planning on
localizing.

Any text you show on a HUD

When your player enters their name for
a high score

Calendar dates & times

FStrings do allow you to manipulate
the variable value, like with
reversing the string or taking a
substring.

Building a URL

Creating a save file name

Hope this helps
Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going.

So if your sending 1000 chars over the network of text datatype is roughly 40kb a pop
If you can do it using just strings your looking at under 16

Hope this helps
Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going.

Thanks, I just switched over all of my variables to use strings rather than text, and the same thing occurs. It works fine if I take down the characters to around 950, but the same thing happens with string vs text

But is the string making it to the server? If so then it’s isolated to the client/game however you wish to think of it. If the string is not making it to the server, then it could be some form of interaction coming back to you from the server. Just keep dividing the problem in two, no different than a binary search of a tree!

I always stick with strings, and convert when I must. Why? every compiler under the sun knows what a string is (nothing more than a arbitrary sequence of bytes, that we glamorize to call it a string). Hence the processor, knows exactly what that is, the processor has no clue as to what Text is, it’s an artificial set of rules, that may or may not help you, imposed not by the compiler but the system in use. For the compiler doesn’t require you to call it text, it could be called WhatNots, and the compiler would be just as happy. Hell the compiler is eventually going to turn everything into a string anyway. So why not just start there, and bypass all the crap. When you have to use something else, because of being forced to do so, well you have no choice, but simpler, working with the processor, is always better, than trying to think of it in some artificial aspect.