From b3b274238723c5eb134fcd190a5db35506109ba7 Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Tue, 7 Mar 2017 21:25:57 +0800 Subject: [PATCH] Fix utf8 encoding in edit fields --- core/um-filters-fields.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/um-filters-fields.php b/core/um-filters-fields.php index acd68b28..8036d1dd 100644 --- a/core/um-filters-fields.php +++ b/core/um-filters-fields.php @@ -379,9 +379,10 @@ add_filter('um_field_non_utf8_value','um_field_non_utf8_value'); function um_field_non_utf8_value( $value ){ - if( ! preg_match('/[^\\p{Common}\\p{Latin}]/u', $value ) ){ - $value = htmlentities( $value ); - } + $encoding = mb_detect_encoding( $value, 'utf-8, iso-8859-1, ascii', true); + if (strcasecmp($encoding, 'UTF-8') !== 0) { + $value = iconv($encoding, 'utf-8', $value); + } return $value; }