[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/voku/portable-ascii/src/voku/helper/ -> ASCII.php (summary)

(no description)

File Size: 1440 lines (48 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 20 functions

  getAllLanguages()
  charsArray()
  charsArrayWithMultiLanguageValues()
  charsArrayWithOneLanguage()
  charsArrayWithSingleLanguageValues()
  clean()
  is_ascii()
  normalize_msword()
  normalize_whitespace()
  remove_invisible_characters()
  to_ascii()
  to_filename()
  to_slugify()
  to_transliterate()
  get_language()
  getData()
  getDataIfExists()
  prepareAsciiAndExtrasMaps()
  prepareAsciiMaps()
  prepareAsciiExtras()

Functions
Functions that are not part of a class:

getAllLanguages()   X-Ref
Get all languages from the constants "ASCII::.*LANGUAGE_CODE".

return: string[]

charsArray(bool $replace_extra_symbols = false)   X-Ref
Returns an replacement array for ASCII methods.

EXAMPLE: <code>
$array = ASCII::charsArray();
var_dump($array['ru']['б']); // 'b'
</code>

param: bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
return: array

charsArrayWithMultiLanguageValues(bool $replace_extra_symbols = false)   X-Ref
Returns an replacement array for ASCII methods with a mix of multiple languages.

EXAMPLE: <code>
$array = ASCII::charsArrayWithMultiLanguageValues();
var_dump($array['b']); // ['β', 'б', 'ဗ', 'ბ', 'ب']
</code>

param: bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
return: array

charsArrayWithOneLanguage(string $language = self::ENGLISH_LANGUAGE_CODE,bool $replace_extra_symbols = false,bool $asOrigReplaceArray = true)   X-Ref
Returns an replacement array for ASCII methods with one language.

For example, German will map 'ä' to 'ae', while other languages
will simply return e.g. 'a'.

EXAMPLE: <code>
$array = ASCII::charsArrayWithOneLanguage('ru');
$tmpKey = \array_search('yo', $array['replace']);
echo $array['orig'][$tmpKey]; // 'ё'
</code>

param: string $language              [optional] <p>Language of the source string e.g.: en, de_at, or de-ch.
param: bool   $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
param: bool   $asOrigReplaceArray    [optional] <p>TRUE === return {orig: string[], replace: string[]}
return: array

charsArrayWithSingleLanguageValues(bool $replace_extra_symbols = false,bool $asOrigReplaceArray = true)   X-Ref
Returns an replacement array for ASCII methods with multiple languages.

EXAMPLE: <code>
$array = ASCII::charsArrayWithSingleLanguageValues();
$tmpKey = \array_search('hnaik', $array['replace']);
echo $array['orig'][$tmpKey]; // '၌'
</code>

param: bool $replace_extra_symbols [optional] <p>Add some more replacements e.g. "£" with " pound ".</p>
param: bool $asOrigReplaceArray    [optional] <p>TRUE === return {orig: string[], replace: string[]}
return: array

clean(string $str,bool $normalize_whitespace = true,bool $keep_non_breaking_space = false,bool $normalize_msword = true,bool $remove_invisible_characters = true)   X-Ref
Accepts a string and removes all non-UTF-8 characters from it + extras if needed.

param: string $str                         <p>The string to be sanitized.</p>
param: bool   $normalize_whitespace        [optional] <p>Set to true, if you need to normalize the
param: bool   $normalize_msword            [optional] <p>Set to true, if you need to normalize MS Word chars
param: bool   $keep_non_breaking_space     [optional] <p>Set to true, to keep non-breaking-spaces, in
param: bool   $remove_invisible_characters [optional] <p>Set to false, if you not want to remove invisible
return: string

is_ascii(string $str)   X-Ref
Checks if a string is 7 bit ASCII.

EXAMPLE: <code>
ASCII::is_ascii('白'); // false
</code>

param: string $str <p>The string to check.</p>
return: bool

normalize_msword(string $str)   X-Ref
Returns a string with smart quotes, ellipsis characters, and dashes from
Windows-1252 (commonly used in Word documents) replaced by their ASCII
equivalents.

EXAMPLE: <code>
ASCII::normalize_msword('„Abcdef…”'); // '"Abcdef..."'
</code>

param: string $str <p>The string to be normalized.</p>
return: string

normalize_whitespace(string $str,bool $keepNonBreakingSpace = false,bool $keepBidiUnicodeControls = false,bool $normalize_control_characters = false)   X-Ref
Normalize the whitespace.

EXAMPLE: <code>
ASCII::normalize_whitespace("abc-\xc2\xa0-öäü-\xe2\x80\xaf-\xE2\x80\xAC", true); // "abc-\xc2\xa0-öäü- -"
</code>

param: string $str                          <p>The string to be normalized.</p>
param: bool   $keepNonBreakingSpace         [optional] <p>Set to true, to keep non-breaking-spaces.</p>
param: bool   $keepBidiUnicodeControls      [optional] <p>Set to true, to keep non-printable (for the web)
param: bool   $normalize_control_characters [optional] <p>Set to true, to convert LINE-, PARAGRAPH-SEPARATOR with "\n" and LINE TABULATION with "\t".</p>
return: string

remove_invisible_characters(string $str,bool $url_encoded = false,string $replacement = '',bool $keep_basic_control_characters = true)   X-Ref
Remove invisible characters from a string.

e.g.: This prevents sandwiching null characters between ascii characters, like Java\0script.

copy&past from https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/Common.php

param: string $str
param: bool   $url_encoded
param: string $replacement
param: bool   $keep_basic_control_characters
return: string

to_ascii(string $str,string $language = self::ENGLISH_LANGUAGE_CODE,bool $remove_unsupported_chars = true,bool $replace_extra_symbols = false,bool $use_transliterate = false,bool $replace_single_chars_only = null)   X-Ref
Returns an ASCII version of the string. A set of non-ASCII characters are
replaced with their closest ASCII counterparts, and the rest are removed
by default. The language or locale of the source string can be supplied
for language-specific transliteration in any of the following formats:
en, en_GB, or en-GB. For example, passing "de" results in "äöü" mapping
to "aeoeue" rather than "aou" as in other languages.

EXAMPLE: <code>
ASCII::to_ascii('�Düsseldorf�', 'en'); // Dusseldorf
</code>

param: string    $str                       <p>The input string.</p>
param: string    $language                  [optional] <p>Language of the source string.
param: bool      $remove_unsupported_chars  [optional] <p>Whether or not to remove the
param: bool      $replace_extra_symbols     [optional]  <p>Add some more replacements e.g. "£" with " pound
param: bool      $use_transliterate         [optional]  <p>Use ASCII::to_transliterate() for unknown chars.</p>
param: bool|null $replace_single_chars_only [optional]  <p>Single char replacement is better for the
return: string

to_filename(string $str,bool $use_transliterate = true,string $fallback_char = '-')   X-Ref
Convert given string to safe filename (and keep string case).

EXAMPLE: <code>
ASCII::to_filename('שדגשדג.png', true)); // 'shdgshdg.png'
</code>

param: string $str
param: bool   $use_transliterate <p>ASCII::to_transliterate() is used by default - unsafe characters are
param: string $fallback_char
return: string

to_slugify(string $str,string $separator = '-',string $language = self::ENGLISH_LANGUAGE_CODE,array $replacements = [],bool $replace_extra_symbols = false,bool $use_str_to_lower = true,bool $use_transliterate = false)   X-Ref
Converts the string into an URL slug. This includes replacing non-ASCII
characters with their closest ASCII equivalents, removing remaining
non-ASCII and non-alphanumeric characters, and replacing whitespace with
$separator. The separator defaults to a single dash, and the string
is also converted to lowercase. The language of the source string can
also be supplied for language-specific transliteration.

param: string                $str
param: string                $separator             [optional] <p>The string used to replace whitespace.</p>
param: string                $language              [optional] <p>Language of the source string.
param: array<string, string> $replacements          [optional] <p>A map of replaceable strings.</p>
param: bool                  $replace_extra_symbols [optional]  <p>Add some more replacements e.g. "£" with "
param: bool                  $use_str_to_lower      [optional] <p>Use "string to lower" for the input.</p>
param: bool                  $use_transliterate     [optional]  <p>Use ASCII::to_transliterate() for unknown
return: string

to_transliterate(string $str,$unknown = '?',bool $strict = false)   X-Ref
Returns an ASCII version of the string. A set of non-ASCII characters are
replaced with their closest ASCII counterparts, and the rest are removed
unless instructed otherwise.

EXAMPLE: <code>
ASCII::to_transliterate('déjà σσς iıii'); // 'deja sss iiii'
</code>

param: string      $str     <p>The input string.</p>
param: string|null $unknown [optional] <p>Character use if character unknown. (default is '?')
param: bool        $strict  [optional] <p>Use "transliterator_transliterate()" from PHP-Intl
return: string

get_language(string $language)   X-Ref
Get the language from a string.

e.g.: de_at -> de_at
de_DE -> de
DE_DE -> de
de-de -> de

param: string $language
return: string

getData(string $file)   X-Ref
Get data from "/data/*.php".

param: string $file
return: array<mixed>

getDataIfExists(string $file)   X-Ref
Get data from "/data/*.php".

param: string $file
return: array<mixed>

prepareAsciiAndExtrasMaps()   X-Ref

return: void

prepareAsciiMaps()   X-Ref

return: void

prepareAsciiExtras()   X-Ref

return: void



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer