官方文档:
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!
相关推荐
// convert a string to uppercase! #include #define N 200 int main(){ char ms[N]; int i; printf("Input ms: "); gets(ms); for(i=0;ms[i];i++) if(ms[i]>='a'&&ms[i]) ms[i]-='\x20'; puts(ms); ...
#include <string.h> #include #include // FUNCTION PROTOTYPES // DEFINES #define SUCCESS 1 #define FAILURE 0 #define TRUE 1 #define FALSE 0 #define MAXVECTDIM 20 #define MAXPATTERN 20 #define ...
#include<string.h> char ch; #define ID 100; #define I 20; char token[20]; int d=0; //int i=0; bool isanum(char ch); bool isaabc(char ch); void scanner_exam(FILE *f); struct option{ int Class; char* ...
FUNCTION ulong CreateFileA(ref string fname, ulong f_access, ulong f_share, ulong f_sec, ulong f_create, ulong f_flag, ulong f_attrib) LIBRARY "kernel32.dll" Function Boolean WriteFile(uLong handle,...
response.write \"数据库连接出错,请检查conn.asp中的连接字符串。\" response.end end if function CloseDB Conn.Close set Conn=Nothing End Function %> dim badword badword=\"\'|and|select|update|...
#include #include #include <string> #include using namespace std;... memset(p,4,BlockSize); printf("----------------------------------------------------------------\n\n"); return 1;...
float ok1=(((float)ok)/1024f/1024f); DecimalFormat myformat1 = new DecimalFormat("0.00"); strFee = myformat1.format(ok1)+"M"; System.out.println(strFee+"M"); } else if(ok>1024 && ok*1024) { ...
String str,strnext,path,fname; //部分变量的声明 JPanel mainpane; JFileChooser choose = new JFileChooser(); //文件对话框 Dialog find,replace; //find为查找对话框,replace对话框 JTextField findtxt,...
让英文字符串超出表格宽度自动换行 word-wrap: break-word; word-break: break-all; 透明背景 <IFRAME src="1.htm" width=300 height=180 allowtransparency></iframe> 获得style内容 obj.style.cssText ...
func dumpFitsTable ( fname string ) { r , err := os . Open ( fname ) if err != nil { panic ( err ) } defer r . Close () f , err := fits . Open ( r ) if err != nil { panic
%-- 10-9-1 下午4:54 --% %-- 10-9-1 下午8:09 --% load('E:\苏雪敬个人资料\苏雪敬-开题报告\程序代码\matlab.mat') %-- 10-9-2 上午9:01 --% load('E:\苏雪敬个人资料\苏雪敬-开题报告\程序代码\matlab.mat') %% *...