x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to pass FString between Unreal and Lua?

Hi, I am using Lua and Unreal, meet some problem about FString and char* , when I pass chinese text, they can not be passed correctly input PringLog("nihao你好")

output LogTemp: Warning: nihao??

 static int PrintLog(lua_State* L)
 {
     FString log = ANSI_TO_TCHAR(lua_tostring(L, -1));
     UE_LOG(LogTemp, Warning, TEXT("%s"), *log);
 
     return 0;
 }
 
 static void RegisterUnrealFunction(lua_State* L)
 {
     lua_pushcfunction(L, PrintLog);
     lua_setglobal(L, "PrintLog");
 }
Product Version: UE 4.19
Tags:
more ▼

asked May 06 '18 at 09:17 AM in C++ Programming

avatar image

CppCode
52 3 5 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Thats text encoding issue, you need to do proper conversion matching lua encoding, you might try UTF8_TO_TCHAR insted. You can read about character encoding here:

https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/StringHandling/CharacterEncoding

http://lua-users.org/wiki/LuaUnicode

more ▼

answered May 06 '18 at 07:47 PM

avatar image

Shadowriver
37.8k 937 172 1123

avatar image CppCode May 11 '18 at 04:43 PM

Thank you, solved my problem

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question