当前位置:网站首页>UE4 essays: fstring, fname and ftext
UE4 essays: fstring, fname and ftext
2022-06-27 20:36:00 【Lao Yan is trying】
FString、FName And FText
UE4 There are three classes that handle strings in , To meet different development needs :FString、FName and FText, Between the three difference by :
① FName
Focus on expressing name , Case insensitive , Non modifiable , The resource names in the engine are FName type , Reusing strings through a lightweight system ,FName When creating, a... Will be created according to the content Hash value , And the same content will only be stored once . adopt Hash Value in progress FName Is faster to find and access , In comparison , There is no need to compare the string contents , Direct comparison Hash Value to distinguish between different FName character string .
The other two strings go to FName Transformation ( Special note ,FText Cannot convert directly to FName, Can be converted to FString, Re convert to FName):
FString str = TEXT("Hello world~");
FText txt = LOCTEXT("keyName", "theValue");
FText txtNS = NSLOCTEXT("TextNameSpace", "keyName", "theValue");
// FString turn FName: unreliable , Missing case information
FName name1 = FName(*str);
FString strFromTxt = txt.ToString();
// FText Turn first FString, Re turn FName: unreliable , Missing case information , The loss of localization information may lead to the potential risk of language conversion
FName name2 = FName(*strFromTxt);
② FString
Nearest std::string, The point is String operation , It provides a large number of operation interfaces for strings , Is the only modifiable string type among the three , And that's why ,FString It is more expensive than the other two strings , Lower performance .
The other two strings go to FString Transformation :
FName name = TEXT("I am Frank~");
FText txt = LOCTEXT("keyName", "theValue");
FText txtNS = NSLOCTEXT("TextNameSpace", "keyName", "theValue");
// FName turn FString: reliable
FString str1 = name.ToString();
// FText turn FString: unreliable , The loss of localization information may lead to the potential risk of language conversion
FString str2 = txt.ToString();
③ FText
The point is Display and localization , Display information that can be directly seen by understandable players , Localization is multilingual processing , Non modifiable . Compared with the other two types ,FText Will be more bloated , But it provides excellent localization capabilities .
The other two strings go to FText Transformation :
FString str = TEXT("Hello world~");
FName name = TEXT("I am Frank~");
// FString turn FText: reliable
FText txt1 = FText::FromString(str);
// FName turn FText: reliable
FText txt2 = FText::FromName(name);
It should be noted that , establish FText The control needs to be named and defined Namespace , And open it in the editor Localize control panel features (Localization Dashboard):
I. Declare a text space macro in the current source file , Create... Within the scope of the macro declaration FText Namespace parameters are not required , It is important to note that the declaration must be undeclared at the end of the source file :
// Source.cpp
// Declare text space macros
#define LOCTEXT_NAMESPACE "MyTextNameSpace"
// Macro declaration scope creation FText
FText txt = LOCTEXT("keyName", "theValue");
// The declaration must be cancelled in the appropriate place
#undef LOCTEXT_NAMESPACE
II. Define the namespace in the editor , Can be used directly in code :
// Use the defined namespace
FText txtNS = NSLOCTEXT("TextNameSpace", "keyName", "theValue");
边栏推荐
- Summary of redis big key problem handling
- 海量数据出席兰州openGauss Meetup(生态全国行)活动,以企业级数据库赋能用户应用升级
- [login interface]
- Database lock problem
- [debug] platform engineering interface debugging
- CSDN 技能树使用体验与产品分析(1)
- 安装NFS服务
- [STL programming] [common competition] [Part 1]
- BAIC makes a brand new pickup truck, which is safe and comfortable
- [STL programming] [common competition] [Part 3]
猜你喜欢

Database index

A distribution fission activity is more than just a circle of friends

主键选择选择自增还是序列?

Redis 大 key 问题处理总结

数据库引擎
![[STL programming] [common competition] [Part 3]](/img/15/0c397d74128268e17897615ad1c84e.png)
[STL programming] [common competition] [Part 3]

海量数据出席兰州openGauss Meetup(生态全国行)活动,以企业级数据库赋能用户应用升级

Web APLS phase - Section 14 - local storage

Web APls 阶段——第十四节——本地存储

Linux system Oracle 19C OEM monitoring management
随机推荐
Connection integration development theme month | drivers of enterprise master data governance
数据库引擎
[required reading for high-quality products] sub query of Oracle database in Linux system
Structs in trust
Oracle 架构汇总
Postman 汉化教程(Postman中文版)
Database index
Data intelligence enters the "deep water area", and data governance is the key
一段时间没用思源,升级到最新的 24 版后反复显示数据加密问题
Hash table - Review
What is a stack?
QT Chinese garbled code
Oracle architecture summary
数仓的字符截取三胞胎:substrb、substr、substring
Logcli Loki command line tool
On the drawing skills of my writing career
Redis cluster Series III
When developing digital collections, how should cultural and Museum institutions grasp the scale of public welfare and Commerce? How to ensure the security of cultural relics data?
Database log
Redis集群