Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't work with UTF-8 encoding
    text
    copied!<p>I load a text file using this code (<strong>my file encoding is UTF-8</strong>) (<a href="https://stackoverflow.com/questions/17580662/how-to-read-a-text-file-that-contains-null-character-in-delphi">How to read a text file that contains &#39;NULL CHARACTER&#39; in Delphi?</a>):</p> <pre><code>uses IOUtils; var s: string; ss: TStringStream; begin s := TFile.ReadAllText('c:\MyFile.txt'); s := StringReplace(s, #0, '', [rfReplaceAll]); //Removes NULL CHARS ss := TStringStream.Create(s); try RichEdit1.Lines.LoadFromStream(ss, TEncoding.UTF8); //UTF8 finally ss.Free; end; end; </code></pre> <p>But my problem is that the <code>RichEdit1</code> doesn't load the whole text. It's not because of Null Characters. It's because of the encoding. When I run the application with this code, It loads the whole text:</p> <pre><code>uses IOUtils; var s: string; ss: TStringStream; begin s := TFile.ReadAllText('c:\MyFile.txt'); s := StringReplace(s, #0, '', [rfReplaceAll]); //Removes NULL CHARS ss := TStringStream.Create(s); try RichEdit1.Lines.LoadFromStream(ss, TEncoding.Default); finally ss.Free; end; end; </code></pre> <p>I changed <code>TEncoding.UTF8</code> to <code>TEncoding.Default</code>. The whole text loaded but it's not in right format and it's not readable.</p> <p>I guess there are some characters that UTF 8 doesn't support. So the loading process stops when it want to load that char.</p> <p>Please Help. Any workarounds? </p> <p>****EDIT:**</p> <p>I'm sure its <code>UTF-8</code> and it plain text. It's a HTML source file. I'm sure it has null charas I saw them using Notepad++ And the value of the <code>Richedit.Plainext</code> is <code>true</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload