Skip to content

Commit

Permalink
added utf32 support
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeioris committed Aug 29, 2020
1 parent f414472 commit e1f3252
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Source/LuaMachine/Private/LuaBlueprintFunctionLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,23 @@ FString ULuaBlueprintFunctionLibrary::LuaValueToUTF8(FLuaValue Value)
return FString(UTF8_TO_TCHAR(Bytes.GetData()));
}

FLuaValue ULuaBlueprintFunctionLibrary::LuaValueFromUTF32(FString String)
{
FTCHARToUTF32 UTF32String(*String);
return FLuaValue((const char*)UTF32String.Get(), UTF32String.Length());
}

FString ULuaBlueprintFunctionLibrary::LuaValueToUTF32(FLuaValue Value)
{
FString ReturnValue;
TArray<uint8> Bytes = Value.ToBytes();
Bytes.Add(0);
Bytes.Add(0);
Bytes.Add(0);
Bytes.Add(0);
return FString(FUTF32ToTCHAR((const UTF32CHAR*)Bytes.GetData(), Bytes.Num() / 4).Get());
}

FLuaValue ULuaBlueprintFunctionLibrary::LuaRunFile(UObject* WorldContextObject, TSubclassOf<ULuaState> State, FString Filename, bool bIgnoreNonExistent)
{
FLuaValue ReturnValue;
Expand Down Expand Up @@ -490,7 +507,9 @@ UTexture2D* ULuaBlueprintFunctionLibrary::LuaValueToTransientTexture(int32 Width

UTexture2D* Texture = UTexture2D::CreateTransient(Width, Height, PixelFormat);
if (!Texture)
{
return nullptr;
}

FTexture2DMipMap& Mip = Texture->PlatformData->Mips[0];
void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
Expand Down
6 changes: 6 additions & 0 deletions Source/LuaMachine/Public/LuaBlueprintFunctionLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ class LUAMACHINE_API ULuaBlueprintFunctionLibrary : public UBlueprintFunctionLib
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Lua")
static FString LuaValueToUTF8(FLuaValue Value);

UFUNCTION(BlueprintCallable, Category = "Lua")
static FLuaValue LuaValueFromUTF32(FString String);

UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Lua")
static FString LuaValueToUTF32(FLuaValue Value);

UFUNCTION(BlueprintCallable, BlueprintPure, meta = (WorldContext = "WorldContextObject"), Category = "Lua")
static int64 LuaValueToPointer(UObject* WorldContextObject, TSubclassOf<ULuaState> State, FLuaValue Value);

Expand Down

0 comments on commit e1f3252

Please sign in to comment.