summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2010-03-05 17:29:30 +0100
committerDerek Jones <derek.jones@ellislab.com>2010-03-05 17:29:30 +0100
commitdaf9c01a2c25515eea87fb4f4c905f49c30d0214 (patch)
treed14be99b84071c0c356de38dd8d8cf381825b79a /system/helpers
parent1e1419229ea85b9928f2b0f7d2bad1f5cefc3946 (diff)
added convert_accented_characters() function to Text Helper
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/text_helper.php48
1 files changed, 43 insertions, 5 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 1e672937b..477260216 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -87,7 +87,7 @@ if ( ! function_exists('character_limiter'))
{
return $str;
}
-
+
$out = "";
foreach (explode(' ', trim($str)) as $val)
{
@@ -136,7 +136,7 @@ if ( ! function_exists('ascii_to_entities'))
$out .= '&#'.array_shift($temp).';';
$count = 1;
}
-
+
$out .= $str[$i];
}
else
@@ -248,7 +248,7 @@ if ( ! function_exists('word_censor'))
// \w, \b and a few others do not match on a unicode character
// set for performance reasons. As a result words like über
// will not match on a word boundary. Instead, we'll assume that
- // a bad word will be bookended by any of these characters.
+ // a bad word will be bookeneded by any of these characters.
$delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
foreach ($censored as $badword)
@@ -352,6 +352,44 @@ if ( ! function_exists('highlight_phrase'))
return $str;
}
}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert Accented Foreign Characters to ASCII
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+if ( ! function_exists('convert_accented_characters'))
+{
+ function convert_accented_characters($match)
+ {
+ if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT))
+ {
+ return $match;
+ }
+
+ include APPPATH.'config/foreign_chars'.EXT;
+
+ if ( ! isset($foreign_characters))
+ {
+ return $match;
+ }
+
+ $ord = ord($match['1']);
+
+ if (isset($foreign_characters[$ord]))
+ {
+ return $foreign_characters[$ord];
+ }
+ else
+ {
+ return $match['1'];
+ }
+ }
+}
// ------------------------------------------------------------------------
@@ -431,7 +469,7 @@ if ( ! function_exists('word_wrap'))
// word into smaller chunks so we'll add it back to our current line
if ($temp != '')
{
- $output .= $temp . "\n" . $line;
+ $output .= $temp."\n".$line;
}
else
{
@@ -456,7 +494,7 @@ if ( ! function_exists('word_wrap'))
return $output;
}
}
-
+
/* End of file text_helper.php */
/* Location: ./system/helpers/text_helper.php */ \ No newline at end of file