Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with encoding in a map #338

Open
trentasis opened this issue Apr 27, 2023 · 2 comments
Open

Problem with encoding in a map #338

trentasis opened this issue Apr 27, 2023 · 2 comments

Comments

@trentasis
Copy link

Hi, I have an error with Nagivs when try to parse a character that it's not UTF8.

I've seen that the error is in the line 116, here:

  return json_encode($arrRet);

I have PHP 5.3.3 and I think the problem is precisely there, in the encoding of the array.

image

@trentasis
Copy link
Author

We were able to circumvent the problem addiing in the file /usr/local/nagvis/share/server/core/classes/NagVisMap.php

This line in 116

$arrRet=unserialize(iconv('UTF-8', 'ASCII//TRANSLIT', utf8_encode(serialize($arrRet))));
return json_encode($arrRet);

Instead of:

return json_encode($arrRet);

@trentasis
Copy link
Author

The previous fix didn't work finally, but we have a new one that fixes non-utf8 characters displayed on the maps.

file /usr/local/nagvis/share/server/core/classes/NagVisMap.php

This line in 116

function mb_unserialize($string) {
$string = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':"$2";'", $string);
return unserialize($string);
}

if (mb_detect_encoding(serialize($arrRet), 'UTF-8', true)) {
}
else{
$arrRet=mb_unserialize(utf8_encode(serialize($arrRet)));
}

    return json_encode($arrRet);
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant