Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Static Public Member Functions | |
static | code2utf8 ($num) |
Returns the utf8 string corresponding to the unicode value (from php.net, courtesy - roman.nosp@m.s@vo.nosp@m.id.lv) More... | |
static | convert ($text, $fromCS, $toCS='utf-8') |
Converts the text between different encodings. More... | |
static | encode_mimeheader ($text, $charset='utf-8') |
Generate a correct base64 encoded header to be used in MIME mail messages. More... | |
static | entities_to_utf8 ($str, $htmlent=true) |
Converts all the numeric entities &#nnnn; or &#xnnn; to UTF-8 Original from laurynas dot butkus at gmail at: http://php.net/manual/en/function.html-entity-decode.php#75153 with some custom mods to provide more functionality. More... | |
static | get_encodings () |
Returns encoding options for select boxes, utf-8 and platform encoding first. More... | |
static | parse_charset ($charset) |
Standardise charset name. More... | |
static | remove_unicode_non_characters ($value) |
There are a number of Unicode non-characters including the byte-order mark (which may appear multiple times in a string) and also other ranges. More... | |
static | reset_caches () |
Reset internal textlib caches. | |
static | specialtoascii ($text, $charset='utf-8') |
Try to convert upper unicode characters to plain ascii, the returned string may contain unconverted unicode characters. More... | |
static | str_max_bytes ($string, $bytes) |
Truncates a string to no more than a certain number of bytes in a multi-byte safe manner. More... | |
static | strlen ($text, $charset='utf-8') |
Multibyte safe strlen() function, uses mbstring or iconv for UTF-8, falls back to typo3. More... | |
static | strpos ($haystack, $needle, $offset=0) |
Find the position of the first occurrence of a substring in a string. More... | |
static | strrchr ($haystack, $needle, $part=false) |
Finds the last occurrence of a character in a string within another. More... | |
static | strrev ($str) |
Reverse UTF-8 multibytes character sets (used for RTL languages) (We only do this because there is no mb_strrev or iconv_strrev) More... | |
static | strrpos ($haystack, $needle) |
Find the position of the last occurrence of a substring in a string UTF-8 ONLY safe strrpos(), uses mbstring, falls back to iconv. More... | |
static | strtolower ($text, $charset='utf-8') |
Multibyte safe strtolower() function, uses mbstring, falls back to typo3. More... | |
static | strtotitle ($text) |
Makes first letter of each word capital - words must be separated by spaces. More... | |
static | strtoupper ($text, $charset='utf-8') |
Multibyte safe strtoupper() function, uses mbstring, falls back to typo3. More... | |
static | substr ($text, $start, $len=null, $charset='utf-8') |
Multibyte safe substr() function, uses mbstring or iconv for UTF-8, falls back to typo3. More... | |
static | trim_utf8_bom ($str) |
Removes the BOM from unicode string More... | |
static | utf8_to_entities ($str, $dec=false, $nonnum=false) |
Converts all Unicode chars > 127 to numeric entities &#nnnn; or &#xnnn;. More... | |
static | utf8ord ($utf8char) |
Returns the code of the given UTF-8 character. More... | |
Static Protected Member Functions | |
static | get_entities_table () |
Returns HTML entity transliteration table. More... | |
static | typo3 ($reset=false) |
Return t3lib helper class, which is used for conversion between charsets. More... | |
Static Protected Attributes | |
static string[] | $noncharacters |
Array of strings representing Unicode non-characters. | |
|
static |
Returns the utf8 string corresponding to the unicode value (from php.net, courtesy - roman.nosp@m.s@vo.nosp@m.id.lv)
int | $num | one unicode value |
string | the UTF-8 char corresponding to the unicode value |
|
static |
Converts the text between different encodings.
It uses iconv extension with //TRANSLIT parameter, falls back to typo3. If both source and target are utf-8 it tries to fix invalid characters only.
string | $text | |
string | $fromCS | source encoding |
string | $toCS | result encoding |
string|bool | converted string or false on error |
|
static |
Generate a correct base64 encoded header to be used in MIME mail messages.
This function seems to be 100% compliant with RFC1342. Credits go to: paravoid (http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283).
string | $text | input string |
string | $charset | encoding of the text |
string | base64 encoded header |
|
static |
Converts all the numeric entities &#nnnn; or &#xnnn; to UTF-8 Original from laurynas dot butkus at gmail at: http://php.net/manual/en/function.html-entity-decode.php#75153 with some custom mods to provide more functionality.
string | $str | input string |
boolean | $htmlent | convert also html entities (defaults to true) |
string | encoded UTF-8 string |
|
static |
Returns encoding options for select boxes, utf-8 and platform encoding first.
array | encodings |
|
staticprotected |
Returns HTML entity transliteration table.
array | with (html entity => utf-8) elements |
|
static |
Standardise charset name.
Please note it does not mean the returned charset is actually supported.
string | $charset | raw charset name |
string | normalised lowercase charset name |
|
static |
There are a number of Unicode non-characters including the byte-order mark (which may appear multiple times in a string) and also other ranges.
These can cause problems for some processing.
This function removes the characters using string replace, so that the rest of the string remains unchanged.
string | $value | Input string |
string | Cleaned string value |
|
static |
Try to convert upper unicode characters to plain ascii, the returned string may contain unconverted unicode characters.
string | $text | input string |
string | $charset | encoding of the text |
string | converted ascii string |
|
static |
Truncates a string to no more than a certain number of bytes in a multi-byte safe manner.
UTF-8 only!
Many of the other charsets we test for (like ISO-2022-JP and EUC-JP) are not supported by typo3, and will give invalid results, so we are supporting UTF-8 only.
string | $string | String to truncate |
int | $bytes | Maximum length of bytes in the result |
string | Portion of string specified by $bytes |
|
static |
Multibyte safe strlen() function, uses mbstring or iconv for UTF-8, falls back to typo3.
string | $text | input string |
string | $charset | encoding of the text |
int | number of characters |
|
static |
Find the position of the first occurrence of a substring in a string.
UTF-8 ONLY safe strpos(), uses mbstring, falls back to iconv.
string | $haystack | the string to search in |
string | $needle | one or more charachters to search for |
int | $offset | offset from begining of string |
int | the numeric position of the first occurrence of needle in haystack. |
|
static |
Finds the last occurrence of a character in a string within another.
UTF-8 ONLY safe mb_strrchr().
string | $haystack | The string from which to get the last occurrence of needle. |
string | $needle | The string to find in haystack. |
boolean | $part | If true, returns the portion before needle, else return the portion after (including needle). |
string|false | False when not found. |
|
static |
Reverse UTF-8 multibytes character sets (used for RTL languages) (We only do this because there is no mb_strrev or iconv_strrev)
string | $str | the multibyte string to reverse |
string | the reversed multi byte string |
|
static |
Find the position of the last occurrence of a substring in a string UTF-8 ONLY safe strrpos(), uses mbstring, falls back to iconv.
string | $haystack | the string to search in |
string | $needle | one or more charachters to search for |
int | the numeric position of the last occurrence of needle in haystack |
|
static |
Multibyte safe strtolower() function, uses mbstring, falls back to typo3.
string | $text | input string |
string | $charset | encoding of the text (may not work for all encodings) |
string | lower case text |
|
static |
Makes first letter of each word capital - words must be separated by spaces.
Use with care, this function does not work properly in many locales!!!
string | $text | input string |
string |
|
static |
Multibyte safe strtoupper() function, uses mbstring, falls back to typo3.
string | $text | input string |
string | $charset | encoding of the text (may not work for all encodings) |
string | upper case text |
|
static |
Multibyte safe substr() function, uses mbstring or iconv for UTF-8, falls back to typo3.
string | $text | string to truncate |
int | $start | negative value means from end |
int | $len | maximum length of characters beginning from start |
string | $charset | encoding of the text |
string | portion of string specified by the $start and $len |
|
static |
|
staticprotected |
Return t3lib helper class, which is used for conversion between charsets.
bool | $reset |
t3lib_cs |
|
static |
Converts all Unicode chars > 127 to numeric entities &#nnnn; or &#xnnn;.
string | $str | input string |
boolean | $dec | output decadic only number entities |
boolean | $nonnum | remove all non-numeric entities |
string | converted string |
|
static |
Returns the code of the given UTF-8 character.
string | $utf8char | one UTF-8 character |
int | the code of the given character |