• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

PROBLEMS READING WITH TEXTFILES

Dear All,

Always I am reading textfiles with texts written in Spanish, Portuguese or French and display them in a memo or listbox I have problems with characters with accents, such as ´á´, ´é´, ´ã´.


Please, do you know as I solve this problem?


Thanks

dict
0
dict
Asked:
dict
  • 2
  • 2
1 Solution
 
SmortexCommented:
How do you read your files ?
What is displayed instead of characters with accents ?
0
 
marcoszorrillaCommented:
Yes, you must use the OemToChar function:

var
str1,str2:Pchar;
OemToChar(str1,str2);

str1 is the string to convert, and str2 ist the converted string.

Best Regards.
Marcos.
0
 
dictAuthor Commented:
Dear marcoszorrilla,

Sorry by my delay in reply you.

Please, how I apply OemToChar(str1,str2); in a listbox?

I am increasing points to 80.

dict
0
 
marcoszorrillaCommented:
procedure TForm1.Button1Click(Sender: TObject);
Try this example:

var
str2:Pchar;
nCont:Integer;
begin
nCont:=0;
listbox1.Items.LoadFromFile('D:\Prueba.txt');


  For nCont:=0 to (Listbox1.Items.Count -1) do
  begin
  OemToChar(PChar(Listbox1.Items[nCont]),str2);
  Listbox1.Items[nCont]:=str2;
  ShowMessage(str2);//Only for test.
  end;

end;

Best Regards
Marcos.
0
 
dictAuthor Commented:
Thank you very much.

I had a code which used a procedure for each change of characters. Now it is will be possible using only a procedure. Great!


Best regards,

dict
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now