I am debugging a Drupal module (this module,webform_import,imports CSV data into the database) and getting some non-printable character causing error in the module. Here is my debugging code
if($v == 'semester'){
dpm('found ' . $v);
}
else
{
dpm('not found ' . $v);
dpm(str_split($v));
}
dpm($v);
The variable $v is passed through following function
function _webform_import_csvfieldtrim($value) {
$value = trim($value);
// Strip off the beginning and ending quotes if necessary.
$value = preg_replace('/^".*"$/', '', $value);
// Remove control characters. Some editors add invalid EOL chars.
// fgetcsv does not handle unicode characters therefore we replace them
// manually. See http://bugs.php.net/bug.php?id=31632.
$value = str_replace('\x00..\x1F\xfe\xff', '', $value);
//$value = str_replace('/[\x00-\x1F\x80-\xFF]/', '', $value);
return $value;
}
This is the output of my debugging
According to the output, $v prints 'semester' but is not equal to string 'semester' and when converted into an array has 11 characters instead of 8. Please let me know if something is wrong with the _webform_import_csvfieldtrim function. Also, I have converted the CSV file's encoding to UTF-8.
Thank you.