ez projects / gwf_textutils


UNIX name Owner Status Version Compatible with
gwf_textutils Georg Franz planning N/A N/A

A small collection of utilities belonging to "text conversion". The
class gwf_TextUtils can be used e.g. for own template operators.

A small collection of utilities belonging to "text conversion".
The class gwf_TextUtils can be used e.g. for own template
Feedback / Bug reports: Georg Franz
uses the php-extensions mbstring and iconv, if they are installed
Attention: The class is not using the textcodec-methods of ez3!!
Use it only if you are using UTF-8 in combination with ISO-8859-1
or if you are using only ISO-8859-1
Otherwise you may have to rewrite some methods!
You need
in your site.ini.append if you are using gwf_TextUtils::add_host
Look there for further infos.
If you are using the "email conversion" you need the javascript code
look at gwf_TextUtils::change_email for further details
javascript code:
function buildtext(friday,monday,tuesday,sunday,thirsday)
function writeMessage(friday,monday,tuesday,sunday,thirsday,christmas)
function displayEmailStatusMsg(sunday,friday,monday,tuesday,thirsday) {
document.MM_returnValue = true;
function MM_displayStatusMsg(msgStr)
document.MM_returnValue = true;
gwf_TextUtils::convertToAlias ($text)
Converts $text to a correct url alias
Tries to replace specials characters like
ä => ae
ö => oe
Tries to convert "Word-Characters" like “
make a url like:
or for german-speaking users:
Heute ist ein schöner Tag mit ss =>
gwf_TextUtils::isUtf8 ($text)
returns true, if $text is ut8-encoded
gwf_TextUtils::textWash ($text)
converts a text for output
usefull for e.g. forum messages
gwf_TextUtils::gwfutf8decode ($text)
checks if the text is utf8-encoded and
converts it back to ISO-8859-1
gwf_TextUtils::gwfutf8encode ($text)
checks if the text is utf8-encoded and
- if not - converts it to utf8
gwf_TextUtils::convert_plain ($text, $break_word = false, $break_width = 60)
Converts a html-text to plain text.
e.g. Usefull for getting a html-mail input and make a
"plain text" copy
text: The input text
break_word: if using word_wrap()
break_width: the cutting position of word_wrap()
gwf_TextUtils::make_keywords ( $text )
Tries to return a "keyword"-string of the given html-text.
Example: If you have html-code of your article-intro this method is
stripping out the html-code, strips out word-duplicates and
the comma-separated string.
e.g. input:

Das geht auf keine Kuhhaut! Im Kuhrier kannst Du bunte und
Nachrichten aus aller Welt lesen. Wenn Du auch eine für uns hast,
schick sie doch an unsere Redaktion!

keine, Kuhhaut, Kuhrier, kannst, bunte, verrückte, Nachrichten,
aller, lesen, schick, unsere, Redaktion
Usefull for the

gwf_TextUtils::strip_search_chars ($contents)
Strips out special characters.
Used for keywords.
Helper function to get a clean mail name
e.g. input:
“John Doe„
becomes to
„John Doe“
gwf_TextUtils::add_host($text, $host = '', $include_images = false)
If you have html-text and want to send it in an email
this method add the host to links and images.

becomes to

$include_images have to be FALSE if you want to add the
host to image-tags too!!
gwf_TextUtils::change_email($email, $link_text='', $first_character='', $last_character = '')
Helper function to convert a email-address for not beeing accessed by
It uses a javascript.
Example: will be converted e.g. to

Real visitors are able to click on e-mail links and the mail program
and E-Mail crawlers are totally lost :-)
The js works with all browsers except Opera.
removes all img-tags from html-input
gwf_TextUtils::convert_url ($text)
a href="
to (
Usefull for plain text emails
gwf_TextUtils::strip_multiple_lines ($text, $line_search = 3, $line_replace = 2)
strips out multiple, empty lines
used by html to plain text conversion for emails
gwf_TextUtils::strip_whitespaces ($text, $break = false)
strips out whitespaces
gwf_TextUtils::html_normal_chars ($text)
the opposite of htmlspecialchars()
gwf_TextUtils::cleanUpHTML ($text)
strips out html-code of $text
gwf_TextUtils::replaceHtmlEntities ($text)
replaces HTML Entities
gwf_TextUtils::replaceWordChars ($contents, $stripUnkowns = true)
replaces characters which come mostly from ms word
by copy & paste
e.g. “ becomes "
gwf_TextUtils::convertSpecialChars($text, $toLower = true)
strtolower() and strtoupper()
don't work for "special characters"
So use mb_strtoupper() or mb_strtolower instead - if installed or
do it manually ...
Strip out all urls
Kind regards,
Emil alias
Georg Franz.



No news yet.

This project has no reviews yet. Be the first one to review it!

No forum messages yet.