From 06814d481c2cbc8ef5da5094a3c4efcd76770b8d Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Fri, 31 Jul 2015 15:54:00 +0200 Subject: [PATCH] UTF-8 encoding cleanups --- api/api_functions.php | 13 ------------- api/groups.php | 14 +------------- api/username.php | 4 +--- api/zipcode.php | 1 - 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/api/api_functions.php b/api/api_functions.php index 4cc66f7..7deb3c2 100644 --- a/api/api_functions.php +++ b/api/api_functions.php @@ -23,12 +23,6 @@ function return_json_response($data, $response_code=200) { die(json_encode($data)); } - -function is_valid_utf8($text) { - return mb_check_encoding($text, 'utf-8'); -} - - function get_db_connection($fetch_mode=NULL, $options=NULL) { if($options == NULL) { $options = array( @@ -133,9 +127,6 @@ function get_user_data($ids) { $u_groups = explode(",",$value); foreach($u_groups as $g) { list($id,$name) = explode(";", $g); - if( !is_valid_utf8($name) ) { - $name = utf8_encode($name); - } if($id == $ACTIVE_GROUP_ID) { $is_active = "1"; } @@ -153,10 +144,6 @@ function get_user_data($ids) { } $result[$key] = _get_cards($value); } - /* Encoding issues? oh yes, utf-8 please */ - elseif( !is_valid_utf8($value) ) { - $result[$key] = utf8_encode($value); - } } $result['is_active'] = $is_active; $results[] = $result; diff --git a/api/groups.php b/api/groups.php index 3ab152f..fefa728 100644 --- a/api/groups.php +++ b/api/groups.php @@ -17,23 +17,11 @@ $sql = "SELECT g.name as group_name, g.id as group_id, g.posix_group, g.mailingl ORDER BY g.name"; $res = $conn->getAll($sql); -/* Encode */ -$results = array(); -foreach($res as $result) { - foreach($result as $key => $value) { - /* Encoding issues? oh yes, utf-8 please */ - if(is_string($value)) { - $result[$key] = utf8_encode($value); - } - } - $results[] = $result; -} - if( DB::isError($res) ) { set_response_code(500); echo json_encode(array('error' => $res->getMessage().". DEBUG: ".$res->getDebugInfo())); die(); } -echo json_encode(array('results' => $results)); +echo json_encode(array('results' => $res)); ?> diff --git a/api/username.php b/api/username.php index 3e81764..6f5c370 100644 --- a/api/username.php +++ b/api/username.php @@ -29,6 +29,4 @@ if( DB::isError($res) ) { } $userExists = $res->numRows() > 0; -echo json_encode(array('result' => $userExists)); - -?> +echo json_encode(array('result' => $userExists)); \ No newline at end of file diff --git a/api/zipcode.php b/api/zipcode.php index 5b9f24a..7ab1056 100644 --- a/api/zipcode.php +++ b/api/zipcode.php @@ -42,4 +42,3 @@ if( count($res) === 1 ) { 'result' => "" )); } -?>