Open 23b opened 5 months ago
Thank you for feedback. But I'm not sure that understand problem with JSON.
Here is the code, that caused my issue:
use ashtokalo\translit\Translit;
$data = ['name'=>'Johñ ”Løng” Silvèr'];
$json = json_encode($data, JSON_UNESCAPED_UNICODE); // {"name":"Johñ ”Løng” Silvèr"}
$json = Translit::object()->convert($json, 'latin'); // {"name":"John "Long" Silver"}
var_export(json_decode($json), true); // NULL
I see it now. Not sure if it's correct way to use the library. Converting JSON in this manner you might found much more issues. For example, converting {"name":"John","namè":"Smith"}
with latin
rules makes JSON invalid because of two identical keys. From my point, JSON must be decoded, than all or required only values might be converted, than it can be encoded back.
Latin includes the following quote replacements:
While I understand the sentiment, it might be problematic in some cases to do this: In my case I applied it to JSON, which became invalid due to to the occurrence of an ” If you want to support normalization of quotes, perhaps a separate class would be practical. It could also include a bigger variety of marks like those: “”‘’‛‟,‚„'"″′´˝`❛❜❝❞‹›«»
Thank you!