1
I have several tables that do Masterdetail among themselves, I will not put the structure here because it is very complex, are 26 tables involved.
The error is as follows: in a table there is a record that when opened by Fastreport it simply gives me a "Access Violation" without foot or head that I can’t see what the problem is, I already opened the table compared to records that work and nothing, nothing to find the problem.
If I ignore that one record it works.
I edited the contents of the table where there is text by putting a simple "x" and it worked, the impression I have that is must have some character in the middle that is not accepted by the combination Postgresql x Fastreport.
The user uses a lot of copy and paste on the system and it is necessary as many documents are in Word to be transported to my system, but I cannot identify which character comes from the word that causes this problem.
The error is below:
[Window Title]
Sistema
[Content]
EAccessViolation error raised, with message : Access violation at address 0040C0B1 in module 'perfil.exe'. Read of address F3746176
[OK]
In Notepad++ already displayed all characters to see if you thought, but no chance.
In the Delphi application I open the record without error, but when I have the report made in Fastreport it gives the error.
The problem is in Postgresql and Fastreport compatibility, but I am already without parameter to solve the problem.
Try to set the charset to be used on the connection before any interaction with the Database SET NAMES='UTF-8' or SET NAMES='LATIN1'
– Marcos Regis
I already do that, the problem is that only in Fastreport he yells
– Marcelo
Then maybe the problem is in Fastreport and not in Postgresql?
– Anonimo
I have already had this problem using Fastreport. The problem is time to "print" "harmful" characters. A simple way would be to use a Normalize() function that removes or replaces harmful characters with others.
– Marcos Regis
{Substitui caracteres especiais por equivalentes ASCII}
Function ReplaceNonAscii(const s: String) : String;
var i, pos: Integer;
const undesiredchars: String= '/ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÚÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùüúþÿ';
const replaces: String= ' AAAAAAACEEEEIIIIDNOOOOOxOUUUbBaaaaaaaceeeeiiiionooooo ouuuby';
Begin 
 SetLength(Result, Length(s));
 for i:=1 to Length(s) do
 if (s[i] in [#32, #48..#57, #65..#90, #97..#122]) then
 Result[i]:= s[i]
 else
 begin
 pos:= AnsiPos(s[i], undesiredchars);
 Result[i] := replaces[pos+1];
 end;
end;
– Marcos Regis
@Marcos Regis this function will replace accented characters, cedilhas and the purpose is not? If it is can not use, because it is a document and has to go with the correct formatting of our wonderful Portuguese language, what I was wondering is if there’s a way I can select the database that shows me which characters are not supported by latin1, I’m searching how to mount this select
– Marcelo
Actually, you’ve tried using
utf8decode
andutf8encode
?– Marcos Regis