uint8*pdata = (uint8*)FMemory::Malloc(1024); FMemory::Memzero(pdata, 1024); uint32 size = (uint32)FMemory::GetAllocSize(pdata); UE_LOG(LogTemp, Warning, TEXT("内存大小{%d}!"), size);
--> UE_LOG(LogTemp, Warning, TEXT("字符串长度{%d}!"), FCStringAnsi::Strlen((ANSICHAR*)pdata));
FString fs = TEXT("1234567890中国"); FString fn = TEXT("abcdefg人"); TCHAR*tt = fs.GetCharArray().GetData(); uint8*ptmp = (uint8*)TCHAR_TO_UTF8(tt); int32 fslen = FCStringAnsi::Strlen((ANSICHAR*)ptmp); UE_LOG(LogTemp, Warning, TEXT("fs len{%d},{%d}"), fslen, FCString::Strlen(tt));
FMemory::Memcpy(pdata, ptmp, fslen); UE_LOG(LogTemp, Warning, TEXT("copy 1 %s"), UTF8_TO_TCHAR(ptmp));
UE_LOG(LogTemp, Warning, TEXT("字符串长度{%d}!"), FCStringAnsi::Strlen((ANSICHAR*)pdata));
tt = fn.GetCharArray().GetData(); ptmp = (uint8*)TCHAR_TO_UTF8(tt); int32 fnlen = FCStringAnsi::Strlen((ANSICHAR*)ptmp); FMemory::Memcpy(pdata + fslen, ptmp, fnlen); UE_LOG(LogTemp, Warning, TEXT("copy 2 %s"), UTF8_TO_TCHAR(pdata));
UE_LOG(LogTemp, Warning, TEXT("字符串长度{%d}!"), FCStringAnsi::Strlen((ANSICHAR*)pdata));
FMemory::Memmove(pdata, pdata + 10, 8); UE_LOG(LogTemp, Warning, TEXT("copy 3 %s"), UTF8_TO_TCHAR(pdata));
FMemory::Memzero(pdata + 8, 18); UE_LOG(LogTemp, Warning, TEXT("copy 3 %s"), UTF8_TO_TCHAR(pdata));
UE_LOG(LogTemp, Warning, TEXT("字符串3长度{%d}!"), FCStringAnsi::Strlen((ANSICHAR*)pdata));
FMemory::Memmove(pdata, pdata + 3, 5); UE_LOG(LogTemp, Warning, TEXT("copy 4 %s"), UTF8_TO_TCHAR(pdata));
UE_LOG(LogTemp, Warning, TEXT("字符串4长度{%d}!"), FCStringAnsi::Strlen((ANSICHAR*)pdata));
FMemory::Memzero(pdata + 5, 3); UE_LOG(LogTemp, Warning, TEXT("copy 4 %s"), UTF8_TO_TCHAR(pdata));
UE_LOG(LogTemp, Warning, TEXT("字符串4长度{%d}!"), FCStringAnsi::Strlen((ANSICHAR*)pdata));
FMemory::Free(pdata);
|