# How to compare a FString in C++ Condition Breakpoints?

**URL:** <https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 24, 2016, 6:52am UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380 "2016-05-24T06:52:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![EthanCS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EthanCS](https://forums.unrealengine.com/u/EthanCS)\
**Post date:** [May 24, 2016, 6:52am UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/1 "2016-05-24T06:52:33Z")

</div>

I have some FString variable needs to be compared and I want to use condition breakpoints to debug. I know in regular C++, i can just use ’ strcmp( newString.\_Bx.\_Buf, “my value”)==0 '. But here is FString. And i try to use some different combinations of several functions, like FString::Equals(…), …

---

<div class="post-metadata">

**Author:** ![KingCole32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KingCole32](https://forums.unrealengine.com/u/KingCole32)\
**Post date:** [May 24, 2016, 8:26am UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/2 "2016-05-24T08:26:49Z")

</div>

You should be able to use the == operator to make a comparison. Since you mention the Equals() method, you may have already read that and the above, but just in case:

* * *

**Comparisons**

The overloaded == operator can be used to compare two FStrings, or to compare an FString to an array of TCHAR\*s. There is also the FString::Equals() method, which takes the FString to test against and the ESearchCase enum for whether or not the comparison should ignore case as arguments. If you want the comparison to ignore case, use ESearchCase::IgnoreCase, and if not, use ESearchCase::CaseSensitive.

```
TestHUDString.Equals(TEXT("Test"), ESearchCase::CaseSensitive);

```

* * *

Information on comparisons, conversions, etc for FString and related types, including the above, can be found [here](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/FString/). Did neither of these methods work?

---

<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:** [May 24, 2016, 10:26am UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/3 "2016-05-24T10:26:15Z")

</div>

Hi,

You should be able to do this in your conditional breakpoint. It’s not pretty, but it should work:

```
wcscmp((wchar_t*)MyString.Data.AllocatorInstance.Data,L"MyText") == 0

```

Hope this helps,

Steve

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b068b18f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b068b18f](https://forums.unrealengine.com/u/anonymous_user_b068b18f)\
**Post date:** [February 19, 2018, 2:38pm UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/4 "2018-02-19T14:38:47Z")

</div>

Some extra findings are that nearly all comparison requires the TEXT macro will not work in conditional breakpoint expression, as it is not recognized by IDE.

---

<div class="post-metadata">

**Author:** ![BujakD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BujakD](https://forums.unrealengine.com/u/BujakD)\
**Post date:** [July 25, 2022, 1:00pm UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/5 "2022-07-25T13:00:04Z")

</div>

> [@Steve\_Robb](#):
>
> `wcscmp((wchar_t*)MyString.Data.AllocatorInstance.Data,L"MyText") == 0`

This works! Thank you

---

<div class="post-metadata">

**Author:** ![lucota90](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lucota90](https://forums.unrealengine.com/u/lucota90)\
**Post date:** [March 25, 2025, 5:18am UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/6 "2025-03-25T05:18:34Z")

</div>

Thanks for that! Unfortunately now I need to compare a FName. Why is it SO painful

---

<div class="post-metadata">

**Author:** ![sad1e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sad1e](https://forums.unrealengine.com/u/sad1e)\
**Post date:** [April 23, 2025, 3:15am UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/7 "2025-04-23T03:15:00Z")

</div>

`MyName.ToString()`

---

<div class="post-metadata">

**Author:** ![Petr\_Smrcek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Petr\_Smrcek](https://forums.unrealengine.com/u/Petr_Smrcek)\
**Post date:** [June 30, 2025, 1:20pm UTC](https://forums.unrealengine.com/t/how-to-compare-a-fstring-in-c-condition-breakpoints/358380/8 "2025-06-30T13:20:09Z")

</div>

I found a partial solution for FName derived from UE natvis. This is shortened expression that works only for Ansi chars:

`strncmp((char*)((FNameEntry&)GNameBlocksDebug[FNAME_TO_BE_TESTED.ComparisonIndex.Value >> FNameDebugVisualizer::OffsetBits][FNameDebugVisualizer::EntryStride * (FNAME_TO_BE_TESTED.ComparisonIndex.Value & FNameDebugVisualizer::OffsetMask)]).AnsiName, "string_to_compare", strlen("string_to_compare")) == 0`

For widechars use wcsncmp and change AnsiName for WideName (not tested though). The generalization would be already too impractical - assuming we can consider this to be practical in the first place.

Note that strncmp compares only first n characters, because UE stores FNames without null terminator. So you can get some false positives, if “string\_to\_compare” is substring of the FName.

Also note that you have to fill FNAME\_TO\_BE\_TESTED and “string\_to\_compare” twice both.

It is ugly, working only sometimes, but hey, it is at least something and I successfully used it.
