Skip to content

Commit

Permalink
* Agrego deteccion de encoding via mbstring, sino intenta convertir …
Browse files Browse the repository at this point in the history
…contenido que ya viene en utf-8

 * Modifico foreach para hacerlo compatible con php 7.0
  • Loading branch information
enfoqueNativo committed Mar 9, 2017
1 parent 77f4863 commit 2db3554
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/SIUToba/rest/http/vista_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ protected function prettyPrint($json)

protected function utf8_encode_fields(array $elements)
{
foreach ($elements as $key => $element) {
if (is_array($element)) {
$elements[$key] = $this->utf8_encode_fields($element);
} else {
$elements[$key] = utf8_encode($element);
$keys_e = array_keys($elements);
foreach ($keys_e as $key) {
if (is_array($elements[$key])) {
$elements[$key] = $this->utf8_encode_fields($elements[$key]);
} elseif (mb_detect_encoding($elements[$key], "UTF-8", true) != "UTF-8") {
$elements[$key] = utf8_encode($elements[$key]);
}
}

Expand Down

0 comments on commit 2db3554

Please sign in to comment.