[SOLVED] TMemo.Lines.LoadFromFile problem with French characters lazarus / 31-LCL ---------------------------------------------------------------------- JD · 2012-03-20 14:06 Hi there everyone, I am using a TMemo to view the contents of text files whose names and contents contain French accented characters. Initially, it was impossible for me to load the text files into the TMemo because they had French names but I got round the problem by passing the filename into the UTF8ToAnsi function TMemo.Lines.LoadFromFile(UTF8ToAnsi(FileName)); Now I can view the contents of the text files but the French words are garbled as shown below: Code: [Select]'Chirurgie' 'Gyn?cologie' 'H?pato-Gastrologie' 'Maternit?' 'M?decine Interne' I've tried all I can (changing the TMemo character set) but I can't get the French text to display properly. I would really appreciate your advice. JD ---------------------------------------------------------------------- CaptBill · 2012-03-20 16:49 I think those characters are written in english as a single quote, so you can search and replace the "?" with a single quote character, couldn't you? ---------------------------------------------------------------------- User137 · 2012-03-20 18:04 I thought TMemo supports UTF by default? What Lazarus and fpc version do you have? Then you can try something like: Code: [Select]memo1.lines.text:=UTF8ToAnsi(memo1.lines.text);Or who knows AnsiToUTF8() ... ---------------------------------------------------------------------- ludob · 2012-03-20 19:04 The characters are encoded in the system code page while lazarus assumes utf8. Convert with Code: [Select]uses LazUTF8; ... Memo1.Lines.Text:=SysToUtf8(Memo1.Lines.Text); QuoteI think those characters are written in english as a single quote, so you can search and replace the "?" with a single quote character, couldn't you? The character happens to be the 'é' but all characters above $7f are converted to '?'. French uses a lot of accented characters that are above $7f. ---------------------------------------------------------------------- joseme · 2012-03-20 22:07 I finally found the answer!!! You should do Code: [Select]  Memo1.Lines.Text := SystoUTF8(ReadFileToString(filename)); and voilá!!! ---------------------------------------------------------------------- JD · 2012-03-20 22:34 Quote from: joseme on March 20, 2012, 11:07:47 pmI finally found the answer!!! You should do Code: [Select]  Memo1.Lines.Text := SystoUTF8(ReadFileToString(filename)); and voilá!!! Ça marche! Muchos gracias joseme. ---------------------------------------------------------------------- JD · 2012-03-21 11:08 Quote from: User137 on March 20, 2012, 07:04:40 pmI thought TMemo supports UTF by default? What Lazarus and fpc version do you have? Then you can try something like: Code: [Select]memo1.lines.text:=UTF8ToAnsi(memo1.lines.text);Or who knows AnsiToUTF8() ... That is what I thought too. BTW I'm using Lazarus 0.9.31 svn 36014 of 17/03/2012 with FPC 2.6.0 on Windows Vista. ---------------------------------------------------------------------- axline · 2016-10-25 12:19 Sorry for necro posting, guys. The 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 memo1.lines.text:=UTF8ToAnsi(memo1.lines.text);used to work fine before updating Lazarus to the version 1.6 (with FPC 3.0.0). Now the same code gives me just '?????' signs instead of Cyrillic symbols. Does anyone else experience the same problem? Is there any easy solution besides downgrading to Lazarus 1.4.4?