ascii helper method accepts only one argument:
$value should always be a string, or something that can be cast into a string. The function converts a string in the UTF-8 encoding into its ASCII equivalent.
This method is useful when communicating with other software platforms that require ASCII, or when complying with protocols (such as HTTP) about how headers, or some values, need to be formatted.
The signature of the
ascii method is:
1public static function ascii(2 $value,3 $language = 'en' // Also accepts `bg` or `de`4 );
ascii method accepts a
$language parameter (which defaults to
en) that can be used:
1use Illuminate\Support\Str;23// Outputs "sht"4echo Str::ascii('щ', 'bg');
ascii method provides support for the following additional languages out of the box:
In Laravel 5.5, the additional language features provided by the Laravel framework have been adapted from the danielstjules/stringy library.
G> Appendix D: Appendix D: Language Specific Replacements contains reference tables for each of the supported language-specific replacements.
1use Illuminate\Support\Str;23// The following will output "a test string"4// in the ASCII encoding.56echo Str::ascii('a test string');