Recent

Author Topic: memo.loadfromfile and accented letters  (Read 6437 times)

Blue1987

  • Full Member
  • ***
  • Posts: 165
memo.loadfromfile and accented letters
« on: September 06, 2011, 12:08:53 am »
dear all... I have a problem...
when I "loadfromfile" from a txt file, it converts all the accented letters ("è", "é", "à", "ù", "ò") into "?",

what should I do?
« Last Edit: September 06, 2011, 12:26:12 am by Blue1987 »

eny

  • Hero Member
  • *****
  • Posts: 1624
Re: memo.loadfromfile and accented letters
« Reply #1 on: September 06, 2011, 07:36:39 am »
Convert ansi text to utf8.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

joseme

  • Full Member
  • ***
  • Posts: 128
    • Logosoft sistemas
Re: memo.loadfromfile and accented letters
« Reply #2 on: September 06, 2011, 11:25:03 am »
This is how I do it:

memo1.Lines.Text := AnsiToUtf8(ReadFileToString('mitextoacentuado.txt'));
un aporte a la comunidad:
http://pascalylazarus.blogspot.com/

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: memo.loadfromfile and accented letters
« Reply #3 on: September 07, 2011, 03:19:58 am »
This is how I do it:

memo1.Lines.Text := AnsiToUtf8(ReadFileToString('mitextoacentuado.txt'));

thank you much!

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9340
  • FPC developer.
Re: memo.loadfromfile and accented letters
« Reply #4 on: September 07, 2011, 01:32:04 pm »
when I "loadfromfile" from a txt file, it converts all the accented letters ("è", "é", "à", "ù", "ò") into "?",

It does not. It keeps all bytes the same as in file. Only when _showing_ it gets converted to UTF8.

So the solution is to convert the content from whatever the encoding the file is to UTF8 between loading and showing

 

TinyPortal © 2005-2018