stringreplace for the copyright symbol lazarus / 31-LCL ---------------------------------------------------------------------- w click · 2022-03-09 14:14 I'm trying to replace '©' with '©' (and a lot of other characters) in a memo from a list in another memo.  It's just not doing anything.  t1 and t2 are the two strings in question.  Can anyone help? Quote if memoreplacements.lines.count>0 then for j:=0 to memoreplacements.lines.count-1 do begin     t:=memoreplacements.lines[j];     t1:=wordfrom(t,1);     t2:=wordfrom(t,2);     memobody.text:=stringreplace(memobody.text,t1,t2,[rfreplaceall]);   end; ---------------------------------------------------------------------- wp · 2022-03-09 14:18 What is wordfrom()? ---------------------------------------------------------------------- Zvoni · 2022-03-09 14:25 Quote from: wp on March 09, 2022, 03:18:31 pmWhat is wordfrom()? at a guess... wordfrom(t,1) --> first word from t and so on Looks like he wants to use a Dictionary... *hinthint* EDIT: considering memo.lines is a TStrings...... why not use the memo.lines in "key/value"-mode? the memo.lines must be added as "@ = ©" Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if memoreplacements.lines.count>0 then   for j:=0 to memoreplacements.lines.count-1 do     memobody.text:=stringreplace(mem obody.text,memoreplacements.lines.Names[j],memoreplacements.lines.Valu eFromIndex[j],[rfreplaceall]); or to stay in his code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if memoreplacements.lines.count>0 then   for j:=0 to memoreplacements.lines.count-1 do begin      t1:=memoreplacements.lines.Names[j];    t2:=memoreplacements.lines.ValueFromIndex[j];    memobody.text:=stringreplace(memobody.text,t1,t2,[rfreplaceall]);  end; ---------------------------------------------------------------------- w click · 2022-03-09 17:24 Oops, sorry.  Wordfrom is excactly as you deduced.  I've been using it so long, I'd forgotten it wasn't standard. I tried Quoteif memoreplacements.lines.count>0 then   for j:=0 to memoreplacements.lines.count-1 do begin      t1:=memoreplacements.lines.Names[j];     t2:=memoreplacements.lines.ValueFromIndex[j];     memobody.text:=stringreplace(memobody.text,t1,t2,[rfreplaceall]);   end; but it didn't work.  I should also have pointed out that my memo of replacements is just a list of symbol, space and replacement, like this: Quote© © ° ° à à ---------------------------------------------------------------------- wp · 2022-03-09 17:52 The code basically is correct. However, I would not call Memo.Lines.Text all the time because this is a very complex operation, and I could imagine that this is the cause of your issue. Rather than that, use a temporary string variable to collect the converted text. See the project in the attachment. ---------------------------------------------------------------------- Zvoni · 2022-03-09 21:04 Quote from: w click on March 09, 2022, 06:24:08 pmOops, sorry.  Wordfrom is excactly as you deduced.  I've been using it so long, I'd forgotten it wasn't standard. I tried Quoteif memoreplacements.lines.count>0 then   for j:=0 to memoreplacements.lines.count-1 do begin      t1:=memoreplacements.lines.Names[j];     t2:=memoreplacements.lines.ValueFromIndex[j];     memobody.text:=stringreplace(memobody.text,t1,t2,[rfreplaceall]);   end; but it didn't work.  I should also have pointed out that my memo of replacements is just a list of symbol, space and replacement, like this: Quote© © ° ° à àYou‘re missing the „=„-symbol Look again at my answer ---------------------------------------------------------------------- w click · 2022-03-10 11:43 Many thanks for people's help.  Sorry, Zvoni, couldn't see the "=" sign you meant. I have made progress and do not understand why it now works.  I went back to my original method, put in a few diagnostics and noticed that it was changing some of them, just not the copyright symbol.  So, I added after "© ©" with another "© &test;" – which worked!  So I deleted the first one and changed "test" to "copy" and that worked.  So, the replacements memo looks exactly the same, but now works. Could the original "©" have hidden codes that make it not work?  Yes, its length now is 2, but it was 5.  As simple as bad data sneaking in? ---------------------------------------------------------------------- Zvoni · 2022-03-10 13:53 Quote from: w click on March 10, 2022, 12:43:07 pmSorry, Zvoni, couldn't see the "=" sign you meant. In your replacement-memo Quotethe memo.lines must be added as "@ = ©" © = © ° = ° à = à