Now I know the position of '#' character in the line (say 14), but I too need to know which is this position in the whole Memo text (say 352)?
How can I get the 352?
Note pad does not show everything ether..I am not sure that I understand you exactly, maybe you went further than what I need.
in any case, you need to make yourself a debugger view of the file that shows the HEX on the left in formatted state and
Ansi on the right. All non-ansi letters to be shown as DOTS or ? marks.
Use a MONO font so that things align.
you can use A TMemoryStream to load the complete contents and then generate a HEX dump text file of it.
I am sure there are LIBS already out there you can compile in to do that for you..
It's possible, but you can't use LoadFromFile(); instead you have to load the binary outside TMemo, p.e. in a TMemoryStream or even in a String (with FileUtil.ReadFileToString()) and replace all problematic characters with whatever you want: a space, a dot, etc. Then you can load that into the TMemo either by using LoadFromStream, if you used a memory stream, or setting TMemo.TextThank you, I will give it a go and let's see.
Edit: which ones can be the "problematic characters", that should be changed?
Is it possible to change a character directly within the MemoryStream, or should I use a string for it?
Extremely strange. Nothing happens. No message at all and the Memo is empty.
I have a form and a Button and a Memo on it.
I used this code:
{... code here ...}
Obviously I did something wrong, but cannot find.
(Maybe it has nothing to do with this thing, but I found earlier that the Memo component cannot load files that are in UTF-16 format, only with UTF-8. I don't know if it does matter in this case?)
What's failing is adding the string to the memo! Nothing works: Memo.Append(), Memo.Lines.Add(), Memo.Lines.AddText(), assigning Memo.Text, assigning Memo.Lines.Text, ... nothing!
And here is the even more curious thing: if the file constains only text, it works: the transposition simply replaces all line-endings with dots/spaces and the whole appears as a single line. But with a binary file,
Does it have anything to do with data being flushed to disk?
Hi lucamar, very sorry for not answering, but I cannot try it for 2 days. Will be back then and will look at it.
Here again.
Tested, doesn't work.
Some remarks (I am on Linux).
The 'notepad.exe' cannot be opened by the usual text editors (xed, medit ...).
But, it can be opened in the Notepad (running via Wine).
As wrote earlier, I found that UTF-16 encoded texts cannot be loaded into the TMemo component by the LoadFromFile. (Why?)
I have to convert/save it to UTF-8 in an external text editor and then Memo will accept it.
Also, if I copy/paste a UTF-16 text directly into the Memo, the text will appear in the Memo flawlessy.
Is it a bug or is it normal?