@@ -437,11 +437,35 @@ private function checkJava(): array {
437437 ];
438438 }
439439 if (!str_contains ($ matches ['encoding ' ], 'UTF-8 ' )) {
440+ $ detectedEncoding = trim ($ matches ['encoding ' ]);
441+ $ phpLocale = setlocale (LC_CTYPE , 0 );
442+ $ phpLcAll = getenv ('LC_ALL ' );
443+ $ phpLang = getenv ('LANG ' );
444+
445+ $ tip = sprintf (
446+ "Java detected encoding \"%s \" but UTF-8 is required. \n\n"
447+ . "**Current PHP environment:** \n"
448+ . "- LC_CTYPE: %s \n"
449+ . "- LC_ALL: %s \n"
450+ . "- LANG: %s \n\n"
451+ . "**To fix this issue:** \n"
452+ . "1. Set LC_ALL and LANG environment variables (e.g., LC_ALL=en_US.UTF-8) for your web server user \n"
453+ . "2. Restart your web server after making changes \n"
454+ . "3. Verify with command: `locale charmap` (should return UTF-8) \n\n"
455+ . 'For more details, see: [Issue #4872](https://github.com/LibreSign/libresign/issues/4872) ' ,
456+ $ detectedEncoding ,
457+ $ phpLocale ?: 'not set ' ,
458+ $ phpLcAll ?: 'not set ' ,
459+ $ phpLang ?: 'not set '
460+ );
440461 return $ this ->result ['java ' ] = [
441462 (new ConfigureCheckHelper ())
442- ->setInfoMessage ('Non-UTF-8 encoding detected. This may cause issues with accented or special characters ' )
463+ ->setInfoMessage (sprintf (
464+ 'Non-UTF-8 encoding detected: %s. This may cause issues with accented or special characters ' ,
465+ $ detectedEncoding
466+ ))
443467 ->setResource ('java ' )
444- ->setTip (' Ensure the system encoding is UTF-8. You can check it using: locale charmap ' ),
468+ ->setTip ($ tip ),
445469 ];
446470 }
447471 return $ this ->result ['java ' ] = [
0 commit comments