# FString/FText doesn't compare correctly?

**URL:** <https://forums.unrealengine.com/t/fstring-ftext-doesnt-compare-correctly/287423>\
**Category:** UI\
**Tags:** fstring, FText, compare, unreal-engine, slate, question, CPP\
**Created:** [July 4, 2014, 7:04pm UTC](https://forums.unrealengine.com/t/fstring-ftext-doesnt-compare-correctly/287423 "2014-07-04T19:04:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJBrune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MJBrune](https://forums.unrealengine.com/u/MJBrune)\
**Post date:** [July 4, 2014, 7:04pm UTC](https://forums.unrealengine.com/t/fstring-ftext-doesnt-compare-correctly/287423/1 "2014-07-04T19:04:48Z")

</div>

FText test = FText().FromString(“ls”);  
if (test.ToString().ToLower().Compare(FText().FromString(“ls”).ToString()))  
{  
OwnerHUD-\>PlayerOwner-\>ClientMessage(“true”);  
}  
else  
{  
OwnerHUD-\>PlayerOwner-\>ClientMessage(“false”);  
}

The above code prints false. Why? it seems to me that they should be equal. Am I wrong?

---

<div class="post-metadata">

**Author:** ![Steve\_Robb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steve\_Robb](https://forums.unrealengine.com/u/Steve_Robb)\
**Post date:** [July 4, 2014, 7:10pm UTC](https://forums.unrealengine.com/t/fstring-ftext-doesnt-compare-correctly/287423/2 "2014-07-04T19:10:10Z")

</div>

FString::Compare is a 3-way comparison function… it returns \<0 if the first string is lexicographically before the second, \>0 if it’s lexicographically after and ==0 if they are lexicographically equal. So they are in fact comparing equal, because Compare is returning zero, which is ‘false’.

If you do this, you should get ‘true’:

```
if (test.ToString().ToLower() == FText().FromString("ls").ToString())

```

Steve

---

<div class="post-metadata">

**Author:** ![MJBrune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MJBrune](https://forums.unrealengine.com/u/MJBrune)\
**Post date:** [July 4, 2014, 8:19pm UTC](https://forums.unrealengine.com/t/fstring-ftext-doesnt-compare-correctly/287423/3 "2014-07-04T20:19:51Z")

</div>

It looks like the FString.Equal function does what I thought FString.Compare did. Makes sense, thanks 🙂
