Solved

PROBLEMS READING WITH TEXTFILES

Posted on 2003-11-16
5
271 Views
Last Modified: 2010-04-05
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
Comment
Question by:dict
  • 2
  • 2
5 Comments
 

Expert Comment

by:Smortex
ID: 9759737
How do you read your files ?
What is displayed instead of characters with accents ?
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 9759750
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
 

Author Comment

by:dict
ID: 9819622
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
 
LVL 3

Accepted Solution

by:
marcoszorrilla earned 80 total points
ID: 9839922
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
 

Author Comment

by:dict
ID: 9840205
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now