Convert File to Utf-8

I'm trying to make a program to repair corrupted subtitle .srt files. After doing some research, I figured out some websites which repair files with this issue are converting it to UTF-8, like subtitletools.com.

I used the method I found in this link: Storing UTF-8 string in a UnicodeString to convert the text I loaded from my .srt file. Many pages suggest this way for converting. But I didn't succeed at last. What am I doing wrong?

This is my code for converting:

procedure Tfrm_main.btn_convertClick(Sender: TObject);
var
  UnicodeStr: UnicodeString;
  UTF8Str: RawByteString;
begin    
  UTF8Str := UTF8Encode(memo_source.Text);
  SetCodePage(UTF8Str, 0, False);
  UnicodeStr := UTF8Str;    
  memo_result.Text := UnicodeStr;    
end;

The program works (the result is weird yet, but had a little difference):

Here is a screenshot of my program trying to convert a .srt file to UTF-8:

.srt file to UTF-8">

19
Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article