[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/lib/ -> textlib.class.php (summary)

(no description)

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

Defines 1 class

textlib:: (16 methods):
  textlib()
  convert()
  substr()
  strlen()
  strtolower()
  strtoupper()
  strpos()
  strrpos()
  specialtoascii()
  encode_mimeheader()
  entities_to_utf8()
  utf8_to_entities()
  trim_utf8_bom()
  get_encodings()
  code2utf8()
  strtotitle()

Defines 16 functions

  textlib_get_instance()

Class: textlib  - X-Ref

This class is used to manipulate strings under Moodle 1.6 an later. As
utf-8 text become mandatory a pool of safe functions under this encoding
become necessary. The name of the methods is exactly the
same than their PHP originals.

A big part of this class acts as a wrapper over the Typo3 charset library,
really a cool group of utilities to handle texts and encoding conversion.

Take a look to its own copyright and license details.
textlib()   X-Ref
Standard constructor of the class. All it does is to instantiate
a new t3lib_cs object to have all their functions ready.

Instead of istantiating a lot of objects of this class everytime
some of their functions is going to be used, you can invoke the:
textlib_get_instance() function, avoiding the creation of them
(following the singleton pattern)

convert($text, $fromCS, $toCS='utf-8')   X-Ref
Converts the text between different encodings. It will use iconv, mbstring
or internal (typo3) methods to try such conversion. Returns false if fails.


substr($text, $start, $len=null, $charset='utf-8')   X-Ref
Multibyte safe substr() function, uses mbstring if available.


strlen($text, $charset='utf-8')   X-Ref
Multibyte safe strlen() function, uses mbstring if available.


strtolower($text, $charset='utf-8')   X-Ref
Multibyte safe strtolower() function, uses mbstring if available.


strtoupper($text, $charset='utf-8')   X-Ref
Multibyte safe strtoupper() function, uses mbstring if available.


strpos($haystack,$needle,$offset=0)   X-Ref
UTF-8 ONLY safe strpos() function, uses mbstring if available.


strrpos($haystack,$needle)   X-Ref
UTF-8 ONLY safe strrpos() function, uses mbstring if available.


specialtoascii($text,$charset='utf-8')   X-Ref
Try to convert upper unicode characters to plain ascii,
the returned string may cantain unconverted unicode characters.


encode_mimeheader($text, $charset='utf-8')   X-Ref
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).


entities_to_utf8($str, $htmlent=true)   X-Ref
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

param: string    $str      input string
param: boolean   $htmlent  convert also html entities (defaults to true)

utf8_to_entities($str, $dec=false, $nonnum=false)   X-Ref
Converts all Unicode chars > 127 to numeric entities &#nnnn; or &#xnnn;.

param: string         input string
param: boolean        output decadic only number entities
param: boolean        remove all nonumeric entities
return: string         converted string

trim_utf8_bom($str)   X-Ref
Removes the BOM from unicode string - see http://unicode.org/faq/utf_bom.html


get_encodings()   X-Ref
Returns encoding options for select boxes, utf-8 and platform encoding first

return: array encodings

code2utf8($num)   X-Ref
Returns the utf8 string corresponding to the unicode value
(from php.net, courtesy - romans@void.lv)

param: int    $num one unicode value
return: string the UTF-8 char corresponding to the unicode value

strtotitle($text)   X-Ref
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!!!

param: string $text
return: string

Functions
Functions that are not part of a class:

textlib_get_instance()   X-Ref
No description



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7