By: Tobi
Date: 2006-08-21
Time: 22:39
|
UTF-8 Problems
Hi,
i try to change my website to utf-8.
My Database is utf-8, i wrote it in the <meta> header and saved my files with UTF-8 Encoding.
But still some german specialchars like the german äöü are shown as �
What can i do`
i use tbs v2. Is it helpful to upgate for this problem?
Thanks tobi
|
By: Skrol29
Date: 2006-08-21
Time: 22:48
|
Re: UTF-8 Problems
You can define the relevant charset at the LoadTemplate() method. This is described in the manual. If the UTF-8 charset doesn't work for you, you can try with a custom function that uses htmlspecialchars(utf8_encode($x)) instead. I had to do that once.
The charset feature is the same between TBS 2 and TBS 3.
|
By: Tobi
Date: 2006-08-21
Time: 23:57
|
Re: UTF-8 Problems
okay, but I wrote this:
$TBS->LoadTemplate('../tmpl/show_filter.tpl', 'UTF-8');
and it helped nothing.
where do i have to add the line you told me? In the class? As function?
Thanks for explaining!
|
By: Skrol29
Date: 2006-08-22
Time: 01:30
|
Re: UTF-8 Problems
I had the same problem. I don't know why, PHP doesn't convert UTF-8 chars like this.
I suggest to use a custom function like this:
function f_utf8_conv($x) {
return htmlspecialchars(utf8_encode($x));
}
...
$TBS->LoadTemplate('../tmpl/show_filter.tpl', '=f_utf8_conv');
|
|
By: Tobi
Date: 2006-08-22
Time: 13:43
|
Re: UTF-8 Problems
thanks, it works perfect.
Is it prossible to change the class, so that i dont have to change it everywhere in the files.
Or set it as default?
|
By: Tobi
Date: 2006-08-22
Time: 22:16
|
Re: UTF-8 Problems
Okay I know how to do it.
you have to open the file: tbs_class.php
and change the line:
// Public methods
function LoadTemplate($File,$HtmlCharSet='=f_utf8_conv') {
|
By: Skrol29
Date: 2006-08-22
Time: 22:32
|
Re: UTF-8 Problems
You can aslo make a small plug-in for that :
<?php
define('TBS_UTF8','clsTbsUtf8');
$GLOBALS['_TBS_AutoInstallPlugIns'][] = TBS_UTF8; // Auto-install
class clsTbsUtf8 {
function OnInstall() {
return array('BeforeLoadTemplate');
}
function BeforeLoadTemplate(&$File,&$HtmlCharSet) {
if ($HtmlCharSet==='') $HtmlCharSet = '=clsTbsUtf8.f_Utf8Conv';
}
function f_Utf8Conv($x) {
return htmlspecialchars(utf8_encode($x));
}
}
?>
|
|
|
Posting in progress.
Please wait...
|