Josh's Changes

This commit is contained in:
2026-04-03 20:43:00 -04:00
parent df06dcc0d7
commit 03825c1048
16 changed files with 216 additions and 54 deletions
+26
View File
@@ -33,3 +33,29 @@ function familyHubWebApiBase(): string {
}
return $sd . '/api';
}
/**
* Bitmask for json_encode so pasted recipe text (or any user string) with malformed UTF-8
* does not make json_encode return false. Without substitution, failed embeds emit an empty
* <script type="application/json"> and the meals UI hits JSON.parse errors.
*
* @return int
*/
function familyHubJsonEncodeShellFlags(): int {
$f = JSON_UNESCAPED_UNICODE;
if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
$f |= JSON_INVALID_UTF8_SUBSTITUTE;
}
return $f;
}
/**
* Lowercase for comparisons and keys. Uses mbstring when available; otherwise ASCII-only strtolower
* so grocery/chore code does not fatal on hosts without ext-mbstring.
*/
function familyHubStrLowerUtf8(string $s): string {
if (function_exists('mb_strtolower')) {
return mb_strtolower($s, 'UTF-8');
}
return strtolower($s);
}