3
* This file implements functions for handling charsets.
5
* This file is part of Quam Plures - {@link http://quamplures.net/}
6
* See also {@link https://launchpad.net/quam-plures}.
8
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
9
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
10
* Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://daniel.hahler.de/}.
12
* {@internal License choice
13
* - If you have received this file as part of a package, please find the license.txt file in
14
* the same folder or the closest folder above for complete license terms.
15
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
16
* then you must choose one of the following licenses before using the file:
17
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
18
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
21
* {@internal Open Source relicensing agreement:
22
* Daniel HAHLER grants Francois PLANQUE the right to license
23
* Daniel HAHLER's contributions to this file and the b2evolution project
24
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
27
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
28
* @author blueyed: Daniel HAHLER.
29
* @author fplanque: Francois PLANQUE.
31
* @todo dh> Move this to some other directory?
3
* This file implements functions for handling charsets
5
* @author {@link http://wonderwinds.com/ Ed Bennett}
6
* @author {@link http://daniel.hahler.de/ Daniel HAHLER}
7
* @author {@link http://fplanque.net/ Francois PLANQUE}
8
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
9
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
35
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
12
if(!defined('QP_MAIN_INIT')) die('fail');
39
* Convert special chars (like german umlauts) to ASCII characters.
41
* @todo dh> IMHO this function should not be included in a file that gets used often/always.
15
* Convert special chars (like german umlauts) to ASCII characters
45
19
function replace_special_chars( $str )
49
if( can_convert_charsets('UTF-8', $evo_charset) && can_convert_charsets('UTF-8', 'ISO-8859-1') /* source */ )
23
if( can_convert_charsets( 'UTF-8', $app_charset ) && can_convert_charsets( 'UTF-8', 'ISO-8859-1' ) /* source */ )
51
$str = convert_charset( $str, 'UTF-8', $evo_charset );
25
$str = convert_charset( $str, 'UTF-8', $app_charset );
53
// TODO: add more...?!
27
// @todo (0000): add more...?!
54
28
$search = array( '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�' ); // iso-8859-1
55
29
$replace = array( 'Ae', 'ae', 'Oe', 'oe', 'Ue', 'ue', 'ss', 'a', 'c', 'e', 'e', 'i', 'o', 'o', 'u' );
57
31
foreach( $search as $k => $v )
58
{ // convert $search to UTF-8
33
// convert $search to UTF-8
59
34
$search[$k] = convert_charset( $v, 'UTF-8', 'ISO-8859-1' );
61
36
$str = str_replace( $search, $replace, $str );