[Gfoss] UTF-8 in mapfile + PostGIS

Ciao, scusate il cross-posting (e l'inglese), ma dato che gli internazionali
non mi danno retta, magari qui sarò più fortunato.

Il problema è strano dato che mi capita sul server di produzione (debian
testing) ma non riesco a riprodurlo in locale (ubuntu dapper).

Per ora ho risolto rinominando il campo, ma mi piacerebbe capire perché
succede.

I have a mapfile UTF8 encoded wich reads data from an UTF8 PostGIS table (note
the NON ASCII labelitem "varietà ":

#---------- start layer vig_camp_2004----------
LAYER
  NAME "vig_camp_2004"
  CONNECTION "host=localhost user=*** password=*** port=5433
dbname=database"
  CONNECTIONTYPE postgis
  TYPE POINT
  DATA "the_geom from vig_camp_2004"
  LABELITEM "varietà "
  TEMPLATE "ttt"
  STATUS default

  CLASS
   NAME "punti di campionamento"
   COLOR 255 255 64
   OUTLINECOLOR 0 0 0
   SIZE 15
   SYMBOL "star"

   LABEL
    ANTIALIAS true
    COLOR 255 255 64
    FONT "arial"
    OUTLINECOLOR 192 0 0
    POSITION ul
    SIZE 7
    TYPE truetype
   END
  END

  PROJECTION
         "init=epsg:3003"
  END

  METADATA
   DESCRIPTION "Campionamenti 2004"
   RESULT_FIELDS "proprietar,varietà "
   LAYER_ENCODING "UTF-8"
   QUERY_BY_POINT "ttt"
   ATTRIBUTE_SEARCH "1"
   WMS_SRS "epsg:3003"
   WMS_TITLE "vig_camp_2004"
   WMS_FEATURE_INFO_MIME_TYPE "text/html"
  END
END

-----
This is the error:
msDrawMap(): Image handling error. Failed to draw layer named 'vig_camp_2004'.
prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual
query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
varietà ::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text
from vig_camp_2004 WHERE the_geom && setSRID('BOX3D(1490836.03506098
4967565.5,1541436.33993902 4995227)'::BOX3D,
find_srid('','vig_camp_2004','the_geom') )'

Postgresql reports the error as 'ERROR: column "variet�" does not exist '

------

Note that the same DB and the same mapfile works fine on my local ubuntu
dapper (which is more UTF8 ready) but fails on my producion server which is
Debian based (and more LATIN9 oriented)

I tried to set default client encoding to UTF8 on the server but it did'nt
help.

It's clearly something to do with mapserver passing the query with the wrong
encoding or postgres not recognising it correctly.

Any hint would be highly appreciated.

--- further info ----

# /usr/lib/cgi-bin/mapserv -v
MapServer version 4.8.3 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER
SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT
SUPPORTS=WCS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=EPPL7 INPUT=POSTGIS
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG

# cat /etc/debian_version
testing/unstable

# file /mapfiles/mapfile.map
/mapfiles/mapfile.map: UTF-8 Unicode text

# psql -l
        List of databases
   Name | Owner | Encoding
-----------+----------+----------
database | postgres | UTF8

--
Alessandro Pasotti
itOpen - "Open Solutions for the Net Age"
w3: www.itopen.it
Linux User# 167502

On Wed, Nov 15, 2006 at 03:47:03PM +0100, Alessandro Pasotti wrote:

Ciao, scusate il cross-posting (e l'inglese), ma dato che gli internazionali
non mi danno retta, magari qui sarò più fortunato.

Il problema è strano dato che mi capita sul server di produzione (debian
testing) ma non riesco a riprodurlo in locale (ubuntu dapper).

Per ora ho risolto rinominando il campo, ma mi piacerebbe capire perché
succede.

I have a mapfile UTF8 encoded wich reads data from an UTF8 PostGIS table (note
the NON ASCII labelitem "varietà ":

#---------- start layer vig_camp_2004----------
LAYER
  NAME "vig_camp_2004"
  CONNECTION "host=localhost user=*** password=*** port=5433
dbname=database"
  CONNECTIONTYPE postgis
  TYPE POINT
  DATA "the_geom from vig_camp_2004"
  LABELITEM "varietà "

Prova:

LABELITEM '"varietÃ"'

(includi il double-quoting nel LABELITEM).

In passato ci ho litigato anch'io, e inviai pure una patch per
il mapserver (per renderlo piu' mixEdCase-friendly), ma se non
sono sicuro la mia patch sia stata accettata...

--strk;