Results 1 to 4 of 4

Thread: export of to csv, xls with czech characters - fixed

  1. #1
    New user
    Join Date
    11-20-13.
    Posts
    2

    Default export of to csv, xls with czech characters - fixed

    I have been using Contao 3.0.6 with EFG 2.0.1 for a while. When exporting form data
    containing czech characters into csv or xls, some of the czech-specific characters were
    missing in the texts, e.g. the submitted text "příliš žluťoučký kůň úpěl nádherné ódy" was
    exported as follows "píliš žluouký k úpl nádherné ódy". The problem concerns the character
    encoding in windows (windows-1250).

    I found how to fix this problem today...

    Code:
    system/modules/efg/drivers/DC_Formdata.php
    ==========================================
    
    --- system/modules/efg/drivers/DC_Formdata.php  2013-03-17 14:16:32.000000000 +0100
    +++ system/modules/efg/drivers/DC_Formdata.php  2013-11-19 23:52:32.502909188 +0100
    @@ -5380,6 +5380,10 @@
                            {
                                    $blnCustomXlsExport = true;
                            }
    +                       else
    +                       {
    +                               include(TL_ROOT.'/plugins/xls_export/xls_export.php');
    +                       }
                    }
                    elseif ($strMode!='csv')
                    {
    @@ -5570,7 +5574,7 @@
    
                    if ($strMode=='csv')
                    {
    -                       header('Content-Type: appplication/csv; charset='.($this->blnExportUTF8Decode ? 'CP1252' : 'utf-8'));
    +                       header('Content-Type: appplication/csv; charset='.($this->blnExportUTF8Decode ? 'CP1250' : 'utf-8'));
                            header('Content-Transfer-Encoding: binary');
                            header('Content-Disposition: attachment; filename="export_' . $this->strFormKey . '_' . date("Ymd_His") .'.csv"');
                            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    @@ -5668,7 +5672,7 @@
    
                                                    if ($this->blnExportUTF8Decode || ($strMode == 'xls' && !$blnCustomXlsExport))
                                                    {
    -                                                       $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
    +                                                       $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1250');
                                                    }
    
                                                    if ($strMode=='csv')
    @@ -5896,7 +5900,7 @@
    
                                                    if ($this->blnExportUTF8Decode || ($strMode == 'xls' && !$blnCustomXlsExport))
                                                    {
    -                                                       $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
    +                                                       $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1250');
                                                    }
                                            }
    
    @@ -5978,12 +5982,13 @@
             */
            public function convertEncoding($strString, $from, $to)
            {
    -               if (USE_MBSTRING)
    -               {
    -                       @mb_substitute_character('none');
    -                       return @mb_convert_encoding($strString, $to, $from);
    -               }
    -               elseif (function_exists('iconv'))
    +               #if (USE_MBSTRING)
    +               #{
    +               #       @mb_substitute_character('none');
    +               #       return @mb_convert_encoding($strString, $to, $from);
    +               #}
    +               #elseif (function_exists('iconv'))
    +               if (function_exists('iconv'))
                    {
                            if (strlen($iconv = @iconv($from, $to . '//IGNORE', $strString)))
                            {
    
    
    system/modules/efg/modules/ModuleFormdataListing.php
    ====================================================
    
    --- system/modules/efg/modules/ModuleFormdataListing.php        2013-03-17 14:16:32.000000000 +0100
    +++ system/modules/efg/modules/ModuleFormdataListing.php        2013-11-19 20:17:43.014309347 +0100
    @@ -1216,7 +1216,7 @@
                            }
                            else // defaults to csv
                            {
    -                               header('Content-Type: appplication/csv; charset=' . ($this->blnExportUTF8Decode ? 'CP1252' : 'utf-8'));
    +                               header('Content-Type: appplication/csv; charset=' . ($this->blnExportUTF8Decode ? 'CP1250' : 'utf-8'));
                                    header('Content-Transfer-Encoding: binary');
                                    header('Content-Disposition: attachment; filename="export_' . $this->strFormKey . '_' . date("Ymd_His") . '.csv"');
                                    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    @@ -1263,7 +1263,7 @@
    
                                    if ($this->blnExportUTF8Decode || ($strExportMode=='xls' && !$blnCustomXlsExport))
                                    {
    -                                       $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
    +                                       $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1250');
                                    }
    
                                    if ($strExportMode=='csv')
    @@ -1830,7 +1830,7 @@
    
                                                    if ($this->blnExportUTF8Decode || ($strExportMode=='xls' && !$blnCustomXlsExport))
                                                    {
    -                                                       $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
    +                                                       $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1250');
                                                    }
                                            }
    @@ -2508,7 +2508,7 @@
                    }
                    else // defaults to csv
                    {
    -                       header('Content-Type: appplication/csv; charset='.($this->blnExportUTF8Decode ? 'CP1252' : 'utf-8'));
    +                       header('Content-Type: appplication/csv; charset='.($this->blnExportUTF8Decode ? 'CP1250' : 'utf-8'));
                            header('Content-Transfer-Encoding: binary');
                            header('Content-Disposition: attachment; filename="export_' . $this->strFormKey . '_' . date("Ymd_His") . '.csv"');
                            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    @@ -2574,7 +2574,7 @@
    
                                                            if ($this->blnExportUTF8Decode || ($strExportMode == 'xls' && !$blnCustomXlsExport))
                                                            {
    -                                                               $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
    +                                                               $strName = $this->convertEncoding($strName, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1250');
                                                            }
                                                    }
    
    @@ -2766,7 +2766,7 @@
    
                                                    if ($this->blnExportUTF8Decode || ($strExportMode == 'xls' && !$blnCustomXlsExport))
                                                    {
    -                                                       $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
    +                                                       $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1250');
                                                    }
                                            }
    
    @@ -3215,12 +3215,12 @@
             */
            public function convertEncoding($strString, $from, $to)
            {
    -               if (USE_MBSTRING)
    -               {
    -                       @mb_substitute_character('none');
    -                       return @mb_convert_encoding($strString, $to, $from);
    -               }
    -               elseif (function_exists('iconv'))
    +               #if (USE_MBSTRING)
    +               #{
    +               #       @mb_substitute_character('none');
    +               #       return @mb_convert_encoding($strString, $to, $from);
    +               #}
    +               if (function_exists('iconv'))
                    {
                            if (strlen($iconv = @iconv($from, $to . '//IGNORE', $strString)))
                            {



    Enjoy!

  2. #2
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,100

    Default

    Hi pdiv,

    you might want to report the issue in the bug tracker: https://bitbucket.org/thk/efg/issues
    Contao Community Moderator
    → Support options

  3. #3
    New user
    Join Date
    11-20-13.
    Posts
    2

    Default

    Thanks, I have posted it also there ....

    https://bitbucket.org/thk/efg/issue/...ech-characters

  4. #4
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,100

    Default

    Alright, thanks a lot.
    Contao Community Moderator
    → Support options

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •