mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Add a setting to force gsm alphabet conversion
This commit is contained in:
parent
fdbc6a0878
commit
59d3e28489
6 changed files with 48 additions and 3 deletions
|
@ -601,6 +601,11 @@ use Monolog\Logger;
|
|||
continue;
|
||||
}
|
||||
|
||||
// If we must force GSM 7 alphabet
|
||||
if ((int) ($users_settings[$id_user]['force_gsm_alphabet'] ?? false))
|
||||
{
|
||||
$text = Tool::convert_to_gsm0338($text);
|
||||
}
|
||||
|
||||
/*
|
||||
Choose phone if no phone defined for message
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace controllers\internals;
|
||||
|
||||
use BenMorel\GsmCharsetConverter\Converter;
|
||||
|
||||
/**
|
||||
* Some tools frequently used.
|
||||
* Not a standard controller as it's not linked to a model in any way.
|
||||
|
@ -412,4 +414,17 @@ namespace controllers\internals;
|
|||
|
||||
return "{$scheme}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform an UTF-8 string into a valid GSM 7 string (GSM 03.38), remplacing invalid chars with best equivalent whenever possible
|
||||
*
|
||||
* @param string $text : Input text to convert into gsm string
|
||||
* @return string : An UTF-8 string with GSM alphabet only
|
||||
*/
|
||||
public static function convert_to_gsm0338(string $text): string
|
||||
{
|
||||
$converter = new Converter();
|
||||
return $converter->cleanUpUtf8String($text, true, '?');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue