-
Notifications
You must be signed in to change notification settings - Fork 169
Added JSON_UNESCAPED_UNICODE flag to json_encode #176
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
Conversation
It helps to dramatically reduce the generated JavaScript file size In my testing, I was able to reduce file size from 170kb to 90kb because I had lots of escaped Cyrillic characters.
SerhiiCho
commented
Mar 6, 2023
It's a tiny change, can we just accept it?
Chomiciak
commented
Feb 18, 2025
What happens if someone's environment is not set to accept files encoded in non-ascii?
SerhiiCho
commented
Feb 19, 2025
What happens if someone's environment is not set to accept files encoded in non-ascii?
It can be as a configuration option "unescape_unicode"
that defaults to false
It would look like this in the config file:
<?php return [ /* * Determines whether to use the JSON_UNESCAPED_UNICODE flag when encoding * translation files to JSON. * * Setting this to true will prevent Unicode characters from being escaped * (e.g., "你好" instead of "\u4f60\u597d"), which can reduce file size * and improve readability. * * Set to false to escape Unicode characters for compatibility. */ 'unescape_unicode' => false, /* * Set the names of files you want to add to generated javascript. * Otherwise all the files will be included. * * 'messages' => [ * 'validation', * 'forum/thread', * ], */ 'messages' => [ ], /* * The default path to use for the generated javascript. */ 'path' => public_path('messages.js'), ];
SerhiiCho
commented
Feb 19, 2025
I can make a PR after I get some feedback. This current PR is also mine from the previous company's account nalognl
It helps to dramatically reduce the generated JavaScript file size
In my testing, I was able to reduce file size from 170kb to 90kb because I had lots of escaped Cyrillic characters.