TIP: Empty String Condition Info

Others may have already been aware of this, but this had me stumped for some time. It caused an error in feedback that caused me a “cosmetic” issue that I have finally reached the bottom of.

Basically, if you use any hidden characters, such as “\n” to form part of a string, (which may also be stored as a variable). The following condition check will cause the following if(sSubText != “”) to fire as if sSubText is valid, even though we do not see any text in the game. i.e. It was causing unwanted blank lines to appear in my feedback format.

string sSubText = GetLocalString(oCurrentItem, "POSTDESCTEXT");
		if(sSubText != "")

Basically, sSubText was something like “\n”, which looks like a blank string when displayed, but is not considered a blank string for purposes of a conditional check.

EDIT: My own testing returned a string length of 3 when the string actually appeared blank. (*)

(*) The overall fix is to ensure that when you intend to add two strings with a “\n” between. that the “\n” is only added when you know you are adding a valid string in the first place. (I was adding one by presumption and should have checked for an invalid string at this point rather than the final result, which by then had the bugged “\n” addition.)