Josh's Changes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user