int32 YourInt = 9000; FString IntAsString = FString::FromInt(YourInt);
https://forums.unrealengine.com/showthread.php?67066-how-to-convert-quot-int32-quot-to-quot-string-quot-in-ue4-c
I have a wiki on exactly this subject!
I cover
FString to uint8 / int32
FString to float
float to FString
int32 to FString
FString to std::string
std:string to FString
~~~
Wiki Link
Rama's Wiki on String Conversions
https://wiki.unrealengine.com/String...oat_to_FString
~~~
C++ Code For You
This is the code you want:
int32 YourInt = 9000; FString IntAsString = FString::FromInt(YourInt);
Enjoy!
Rama
https://wiki.unrealengine.com/String_Conversions:_FString_to_FName,_FString_to_Int32,_Float_to_FString
Overview
- FString to FName
- std::string to FString
- FString and FCString Overview
- FString to Integer
- FString to Float
- Float/Integer to FString
- UE4 C++ Source Header References
All the header files I refer to in this tutorial are found in
your UE4 install directory / Engine / Source
you will probably want to do a search for them from this point :)
Converting FString to FNames
Say we have
FString TheString = "UE4_C++_IS_Awesome";
To convert this to an FName you do:
FName ConvertedFString = FName(*TheString);
std::string to FString
#include <string> //.... some function { std::string TestString = "Happy"; FString HappyString(TestString.c_str()); }
FString to std::string
#include <string> //.... FString UE4Str = "Flowers"; std::string MyStdString(TCHAR_TO_UTF8(*UE4Str));
FCString Overview
Converting FString to Numbers
The * operator on FStrings returns their TCHAR* data which is what FCString functions use.
If you cant find the function you want in FStrings (UnrealString.h) then you should check out the FCString functions (CString.h)
I show how to convert from FString to FCString below:
Say we have
FString TheString = "123.021";
FString to Integer
int32 MyShinyNewInt = FCString::Atoi(*TheString);
FString to Float
float MyShinyNewFloat = FCString::Atof(*TheString);
Note that Atoi and Atof are static functions, so you use the syntax FCString::TheFunction to call it :)
Float/Integer to FString
FString NewString = FString::FromInt(YourInt); FString VeryCleanString = FString::SanitizeFloat(YourFloat);
Static functions in the UnrealString.h :)
UE4 Source Header References
CString.h UnrealString.h NameTypes.h
See CString.h for more details and other functions like
atoi64 (string to int64) Atod (string to double precision float)
For a great deal of helpful functions you will also want to look at
UnrealString.h for direct manipulation of FStrings!
For more info on FNames check out
NameTypes.h
Enjoy!
'게임엔진(GameEngine) > Unreal4' 카테고리의 다른 글
Behavior tree Selector , Sequence 의 차이 Difference (0) | 2016.08.02 |
---|---|
Set Array Elem 사용시 주의 점 (0) | 2016.07.29 |
c++ 에서 블루프린트에 스트링/로그 출력 (0) | 2016.07.20 |
TSharedPtr, TWeakPtr 에 대한 Dynamic cast 는 지원하지 않음 , NO RTTI (0) | 2016.07.17 |
how to create only header file while exist inside include generate.h ? , 하지만 이미 자동으로 UHT 가 자동으로 만든다 (0) | 2016.07.13 |