[fpc-pascal] Problems with Postgresql Character Encoding

Andrew Brunner atbrunner at aurawin.com
Tue Sep 25 19:21:02 CEST 2012

My cloud file/folder sync client desktop app builds and maintains a 
manifest of all files and folders from a specified starting point. I use 
this manifest to synchronize disk entries across devices.  It uses HTTP 
requests and XML to carry out all transactions.  Meaning there is no 
TSQLConnection.  The problem is that the HTTP server receives the data 
as XML and refuses to post changes.  If data (in updates or inserts) 
contains non-supported UTF8 characters postgresql rejects with character 
encoding notices.

I've tried with using AnsiToUTF8 and UTF8toAnsi.  That works for email 
messages.  However, since sync code has to scan tens of thousands of 
disk files/folders I don't think it's good for battery and memory 
consumption for a background app to consume cpu resources in this case 
going between 2 forms of the same file/folder name.

I need to be able to take advantage of Postgresql's client encoding 
method.  I know postgresql allows me to tell the server that the 
connection is presently character set "LATIN1".  And presumably 
postgresql server will convert what it needs to my database encoding of 


This does nothing for me when Connection is a postgresql connection.

Anyone have any experience with postgresql character sets / encoding???

I can't hard-code any one character set because users from 1 region will 
have different encoding needs than another.

Any help, or comments is greatly needed.

Andrew Brunner

Aurawin LLC

Aurawin is a great new place to store, share, and enjoy your
photos, videos, music and more.

More information about the fpc-pascal mailing list