summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/application/config/foreign_chars.php64
-rw-r--r--system/helpers/text_helper.php48
2 files changed, 107 insertions, 5 deletions
diff --git a/system/application/config/foreign_chars.php b/system/application/config/foreign_chars.php
new file mode 100644
index 000000000..8d70a2f62
--- /dev/null
+++ b/system/application/config/foreign_chars.php
@@ -0,0 +1,64 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| Foreign Characters
+| -------------------------------------------------------------------
+| This file contains an array of foreign characters for transliteration
+| conversion used by the Text helper
+|
+*/
+$foreign_characters = array('223' => "ss", // ß
+ '224' => "a",
+ '225' => "a",
+ '226' => "a",
+ '229' => "a",
+ '227' => "ae",
+ '230' => "ae",
+ '228' => "ae",
+ '231' => "c",
+ '232' => "e", // è
+ '233' => "e", // é
+ '234' => "e", // ê
+ '235' => "e", // ë
+ '236' => "i",
+ '237' => "i",
+ '238' => "i",
+ '239' => "i",
+ '241' => "n",
+ '242' => "o",
+ '243' => "o",
+ '244' => "o",
+ '245' => "o",
+ '246' => "oe", // ö
+ '249' => "u",
+ '250' => "u",
+ '251' => "u",
+ '252' => "ue", // ü
+ '255' => "y",
+ '257' => "aa",
+ '269' => "ch",
+ '275' => "ee",
+ '291' => "gj",
+ '299' => "ii",
+ '311' => "kj",
+ '316' => "lj",
+ '326' => "nj",
+ '353' => "sh",
+ '363' => "uu",
+ '382' => "zh",
+ '256' => "aa",
+ '268' => "ch",
+ '274' => "ee",
+ '290' => "gj",
+ '298' => "ii",
+ '310' => "kj",
+ '315' => "lj",
+ '325' => "nj",
+ '352' => "sh",
+ '362' => "uu",
+ '381' => "zh",
+ );
+
+
+/* End of file foreign_chars.php */
+/* Location: ./system/application/config/foreign_chars.php */ \ No newline at end of file
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