Issue parsing integers "08" and "09" using FDefaultValueHelper::ParseInt()

I’m using Unreal Engine 4.27.

I’ve come across a strange issue when parsing certain integers using FDefaultHelper::ParseInt().
Steps to reproduce:

int Parsed;
FString InString="08"; // "09" same issue. No issues with "01"..."07", "8" or "9"
FDefaultValueHelper::ParseInt(InString,Parsed);
// Value of Parsed is 0

From what I’ve been able to tell, the only strings that cause this issue are “08” and “09”.

The problem here is that ParseInt has 2 special parsing modes for hexadecimal and octal.

If your text is preceded by: 0x e.g. 0x12 it uses base 16 (hexadecimal).
If your text is preceded by: 0 e.g. 08 it uses base 8 (octal).

I’d recommend you instead use FCString::Atoi, see UKismetStringLibrary::Conv_StringToInt

1 Like

Thanks for taking the time to explain. That makes sense and solved my issue.

Using UKismetStringLibrary::Conv_StringToInt() works in my case.