diff --git a/plugins/iconv.inc b/plugins/iconv.inc deleted file mode 100755 index 3f493ff..0000000 --- a/plugins/iconv.inc +++ /dev/null @@ -1,46 +0,0 @@ - 'feeds_tamper_iconv_form', - 'callback' => 'feeds_tamper_iconv_callback', - 'name' => 'Convert charset', - 'multi' => 'loop', - 'category' => 'Text', -); - -function feeds_tamper_iconv_form($importer, $element_key, $settings) { - $form = array(); - $charset_options = array( - 'ISO-8859-1' => 'ISO-8859-1', - 'ISO-8859-2' => 'ISO-8859-2', - 'UTF-8' => 'UTF-8', - 'Windows-1250' => 'Windows-1250', - 'Windows-1252' => 'Windows-1252', - ); - $form['charset_from'] = array( - '#type' => 'select', - '#title' => t('From'), - '#description' => t('The source value charset.'), - '#required' => TRUE, - '#options' => $charset_options, - '#default_value' => isset($settings['charset_from']) ? $settings['charset_from'] : 'Windows-1250', - ); - $form['charset_to'] = array( - '#type' => 'select', - '#title' => t('To'), - '#description' => t('The target value charset.'), - '#required' => TRUE, - '#options' => $charset_options, - '#default_value' => isset($settings['charset_to']) ? $settings['charset_to'] : 'UTF-8', - ); - return $form; -} - -function feeds_tamper_iconv_callback($result, $item_key, $element_key, &$field, $settings, $source) { - $field = iconv($settings['charset_from'], $settings['charset_to'], $field); -} diff --git a/plugins/utf8.inc b/plugins/utf8.inc new file mode 100755 index 0000000..d0ae24c --- /dev/null +++ b/plugins/utf8.inc @@ -0,0 +1,36 @@ + 'feeds_tamper_utf8_form', + 'callback' => 'feeds_tamper_utf8_callback', + 'name' => 'Convert charset to UTF-8', + 'multi' => 'loop', + 'category' => 'Text', +); + +function feeds_tamper_utf8_form($importer, $element_key, $settings) { + $form = array(); + $charset_options = array( + 'ISO-8859-1' => 'ISO-8859-1', + 'ISO-8859-2' => 'ISO-8859-2', + 'Windows-1250' => 'Windows-1250', + 'Windows-1252' => 'Windows-1252', + ); + $form['charset_from'] = array( + '#type' => 'select', + '#title' => t('Source character set'), + '#required' => TRUE, + '#options' => $charset_options, + '#default_value' => isset($settings['charset_from']) ? $settings['charset_from'] : 'Windows-1250', + ); + return $form; +} + +function feeds_tamper_utf8_callback($result, $item_key, $element_key, &$field, $settings, $source) { + $field = drupal_convert_to_utf8($field, $settings['charset_from']); +}