function strip_utf8mb4_webform_submission_presave in Strip 4-byte UTF8 7
Implement hook_webform_submission_presave().
File
- ./
strip_utf8mb4.module, line 29 - Allow users to Strip 4-byte UTF8 characters. overly long 2 byte sequences, as well as characters above U+10000, and reject overly long 3 byte sequences and UTF-16
Code
function strip_utf8mb4_webform_submission_presave($node, &$submission) {
$components = $node->webform['components'];
// The submission has no data about the type of the values, so we go through
// the componen saved in the node.
foreach ($components as $cid => $component) {
if (isset($component['type']) && _webform_strip_utf8mb4_for($component['type'])) {
$component_value =& $submission->data[$cid]['value'];
if (isset($component_value)) {
if (is_array($component_value) && count($component_value) > 0) {
foreach ($component_value as &$value) {
$value = _strip_utf8mb4_for_text_fields($value, variable_get('strip_utf8mb4_replace_string', '--'));
}
}
elseif (is_string($component_value) && $component_value != '') {
$component_value = _strip_utf8mb4_for_text_fields($component_value, variable_get('strip_utf8mb4_replace_string', '--'));
}
}
}
}
}