[Cartoweb-users] ClientExportCSV : trouble with header type sended

Bruno Friedmann bruno at ioda-net.ch
Wed Apr 23 04:00:04 EDT 2008


Hi All,

Facing to bugs in excel ( was unable to directly open a csv exported in utf-8)
I've made a look a ClientExportCSV :

There's a little mistake at the end

getExport look if a separator is defined in configuration
        if (!is_null($this->getConfig()->separator)) {
            $sep = $this->getConfig()->separator;
        } else {
            $sep = ';';
        }

But in
   public function output() {
      header('Content-Type: application/csv-tab-delimited-table; charset='
              . Encoder::getCharset());
       header('Content-disposition: filename=' . $this->fileName);
       print $this->getExport()->getContents();
       return '';
    }
We found a forced Content-Type which doesn't exist in normal mime.types !
under debian
cat mime.types | grep csv
text/comma-separated-values             csv
cat mime.types | grep tsv
text/tab-separated-values               tsv
under opensuse
text/x-comma-separated-values 		csv
ext/tab-separated-values 		tsv

This pose some trouble. also the .csv extension is forced.

After long research it would be clear that excel doesn't understand UTF-8 (only UTF-16 but in a very Microsoft way)

I think that it could be possible to modify a bit the plugin to use .tsv extension and tab,
comma and .csv for default. Allowing to send the correct content-type header.

What are your ideas about that ?

-- 

     Bruno Friedmann


More information about the Cartoweb-users mailing list