I realized that this feature is not treating UTF-8 as expected.
The Properties column saves the text which contains 莽 and 茫 as \u00e7 and \u00e3, respectively.
Does anybody know what is causing this behaviour?
{"attributes":{"observation":"Altera\u00e7\u00e3o"},"old":{"observation":null}}
It's a json column and because of this everything is JSON encoded. If you read from the properties they should be back to utf8 encoding.
https://www.ietf.org/rfc/rfc4627.txt
2.5. Strings
The representation of strings is similar to conventions used in the C
family of programming languages. A string begins and ends with
quotation marks. All Unicode characters may be placed within the
quotation marks except for the characters that must be escaped:
quotation mark, reverse solidus, and the control characters (U+0000
through U+001F).
Any character may be escaped. If the character is in the Basic
Multilingual Plane (U+0000 through U+FFFF), then it may be
represented as a six-character sequence: a reverse solidus, followed
by the lowercase letter u, followed by four hexadecimal digits that
encode the character's code point. The hexadecimal letters A though
F can be upper or lowercase. So, for example, a string containing
only a single reverse solidus character may be represented as
"\u005C".
Alternatively, there are two-character sequence escape
representations of some popular characters. So, for example, a
string containing only a single reverse solidus character may be
represented more compactly as "\\".
To escape an extended character that is not in the Basic Multilingual
Plane, the character is represented as a twelve-character sequence,
encoding the UTF-16 surrogate pair. So, for example, a string
containing only the G clef character (U+1D11E) may be represented as
"\uD834\uDD1E".
The only solution to prevent this would be to pass the JSON_UNESCAPED_UNICODE constant.
https://www.php.net/manual/en/json.constants.php
But we rely on the eloquent attribute casting - so you have to check how to get it into there.
just add this method to \vendor\spatie\laravel-activitylog\src\Models\Activity.php
protected function asJson($value)
{
return json_encode($value, JSON_UNESCAPED_UNICODE);
}
just add this method to \vendor\spatie\laravel-activitylog\src\Models\Activity.php
protected function asJson($value)
{
return json_encode($value, JSON_UNESCAPED_UNICODE);
}
Tahnk u so much. Its work for me.
Most helpful comment
just add this method to \vendor\spatie\laravel-activitylog\src\Models\Activity.php
protected function asJson($value)
{
return json_encode($value, JSON_UNESCAPED_UNICODE);
}