Skip to content
Snippets Groups Projects
Commit a7fbb9d2 authored by Rimas Kudelis's avatar Rimas Kudelis
Browse files

Added support for Windows-125* character sets in CSV import.

Excel still does not export CSV as UTF-8, using the 8-bit system character set instead, so support for these charsets comes in handy.
This also updates the `convertCharacterEncoding()` function to be a bit smarter when choosing its backend.
parent 46bf2a4c
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,19 @@ class Import_Utils_Helper {
static $AUTO_MERGE_OVERWRITE = 2;
static $AUTO_MERGE_MERGEFIELDS = 3;
static $supportedFileEncoding = array('UTF-8'=>'UTF-8', 'ISO-8859-1'=>'ISO-8859-1');
static $supportedFileEncoding = array(
'UTF-8'=>'UTF-8',
'ISO-8859-1'=>'ISO-8859-1',
'Windows-1250'=>'Windows-1250',
'Windows-1251'=>'Windows-1251',
'Windows-1252'=>'Windows-1252',
'Windows-1253'=>'Windows-1253',
'Windows-1254'=>'Windows-1254',
'Windows-1255'=>'Windows-1255',
'Windows-1256'=>'Windows-1256',
'Windows-1257'=>'Windows-1257',
'Windows-1258'=>'Windows-1258',
);
static $supportedDelimiters = array(','=>'comma', ';'=>'semicolon');
static $supportedFileExtensions = array('csv','vcf');
......
......@@ -70,7 +70,10 @@ class Import_FileReader_Reader {
}
public function convertCharacterEncoding($value, $fromCharset, $toCharset) {
if (function_exists("mb_convert_encoding")) {
if (function_exists("mb_convert_encoding")
&& function_exists("mb_list_encodings")
&& in_array($fromCharset, mb_list_encodings())
&& in_array($toCharset, mb_list_encodings())) {
$value = mb_convert_encoding($value, $toCharset, $fromCharset);
} else {
$value = iconv($fromCharset, $toCharset, $value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment