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

UTF-8 encoding not working on v1.8 for php 5.3+ #139

Closed
acanuto opened this issue May 12, 2021 · 3 comments
Closed

UTF-8 encoding not working on v1.8 for php 5.3+ #139

acanuto opened this issue May 12, 2021 · 3 comments

Comments

@acanuto
Copy link

acanuto commented May 12, 2021

UTF-8 encoding not working on my end every time I send and error/ exception it removes all special characters

@robbieaverill
Copy link
Contributor

Hi @acanuto, can you please provide some steps to reproduce?

@acanuto
Copy link
Author

acanuto commented May 12, 2021

@robbieaverill thanks for the quick reply, here goes the code block I'm using

`require_once "vendor/raygun4php/src/Raygun4php/RaygunClient.php";

$client = new \Raygun4php\RaygunClient("API TOKEN REMOVED");
$name = "É";

try {
throw new Exception("Name: " . $name);
} catch (Exception $exception) {
$client->SendException($exception);
}`

on Raygun appears "Exception: Name: "

Using PHP 7.3 on a shared server hosting.
Wasn't able to run the newest version of raygun4php

@acanuto
Copy link
Author

acanuto commented May 17, 2021

Added setlocale(LC_CTYPE, 'pt_PT');

function toJsonRemoveUnicodeSequences($struct) { setlocale(LC_CTYPE, 'pt_PT'); return preg_replace_callback("/\\\\u([a-f0-9]{4})/", function($matches){ return iconv('UCS-4LE','UTF-8',pack('V', hexdec("U$matches[1]"))); }, json_encode($struct)); }

It's now working like it should, going to close the issue =)

@acanuto acanuto closed this as completed May 17, 2021
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

2 participants