|
|
Joined: Aug 2004
Posts: 490 Likes: 2
Addict
|
|
Addict
Joined: Aug 2004
Posts: 490 Likes: 2 |
My board currently uses ISO-8859-2 but I feel that it's time to switch to UFT-8 as this has become the standard in recent years.
How would I go about making the switch on my UBB board, so that all previous posts will also be encoded in UTF-8?
|
|
|
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88 |
I have never attempted to change the encoding myself. But I do know there are caveats in doing so.Meaning a possible corrupted database.
As I recall you will see the option while installing UBB. After that you would need to edit your database. It was discussed for version 8 and I believe the one file in question was generic.php
Blue Man Group There is no such thing as stupid questions. Just stupid answers
|
|
|
|
|
Joined: Aug 2004
Posts: 490 Likes: 2
Addict
|
|
Addict
Joined: Aug 2004
Posts: 490 Likes: 2 |
Is the change done by just altering the encoding settings for the database in phpMyAdmin and then editing generic.php?
|
|
|
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88 |
I am not really sure. Somebody smarter than me will need to answer. Like I said I never attempted it. I am just aware there have been issues in doing so. So I never tried it myself.
Blue Man Group There is no such thing as stupid questions. Just stupid answers
|
|
|
|
|
Joined: Jun 2006
Posts: 16,532 Likes: 150
|
|
Joined: Jun 2006
Posts: 16,532 Likes: 150 |
If I recall you just need to update the "charset" value in the general language file to read "UTF-8".
|
|
|
|
|
Joined: Aug 2004
Posts: 490 Likes: 2
Addict
|
|
Addict
Joined: Aug 2004
Posts: 490 Likes: 2 |
If I recall you just need to update the "charset" value in the general language file to read "UTF-8". That needs to be done when it comes to Threads settings, yes, but before that I need to convert the entire database to UTF-8 or else I'll end up with jumbled up characters in many areas.
|
|
|
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88 |
That is what the issue was! Finally jogged my memory. Currently there is not a built in script to convert the tables. As long as you start with a net new install it is okay. From the old version 8 change log that became vaporware. By Rick: The other big step is the conversion of the table types to a character set of utf8. All of the data within the various tables will be converted to utf8, and all timestamps will be converted to GMT. Yes, version 8 is going to be a very large update. All of the tables will be changing, lowercasing, utf8, splitting up the posts table, etc. All of the scripts will be changing, the templates, skins, etc. It's probably more major than the version 7 upgrade was wink
It's probably going to be easiest if you're already running version 7.5.x when version 8 comes out so it can upgrade directly, oth
Blue Man Group There is no such thing as stupid questions. Just stupid answers
|
|
|
|
|
Joined: Aug 2004
Posts: 490 Likes: 2
Addict
|
|
Addict
Joined: Aug 2004
Posts: 490 Likes: 2 |
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
set_time_limit(360000);
ini_set("memory_limit","9000M");
header ('Content-type: text/html; charset=ISO-8859-2');
$db = new PDO('mysql:host=localhost;port=3306; dbname=mecz_ubb;', 'root', 'mecz');
// ubbt_ADDRESS_BOOK ubbt_ADMIN_LOG ubbt_ADMIN_SEARCHES ubbt_ANNOUNCEMENTS ubbt_BANNED_EMAILS ubbt_BANNED_HOSTS ubbt_BANNED_USERS ubbt_BBCODE ubbt_CACHE ubbt_CACHED_PERMISSIONS ubbt_CALENDAR_EVENTS ubbt_CAPTCHA ubbt_CATEGORIES ubbt_CENSOR_LIST ubbt_CHECK_DATA ubbt_CP_PERMISSIONS ubbt_DISPLAY_NAMES ubbt_FILES ubbt_FORUMS ubbt_FORUM_LAST_VISIT ubbt_FORUM_PERMISSIONS ubbt_GRAEMLINS ubbt_GROUPS ubbt_LANGUAGES ubbt_MAILER ubbt_MEMBER_SEARCHES ubbt_MODERATORS ubbt_MODERATOR_NOTIFICATIONS ubbt_ONLINE ubbt_PAYPAL_DATA ubbt_PERMISSION_LIST ubbt_POINTER_DELETE ubbt_POLL_DATA ubbt_POLL_OPTIONS ubbt_POLL_VOTES ubbt_PORTAL_BOXES ubbt_POSTS
$table = "ubbt_POSTS";
$q = $db->query("DESCRIBE $table ");
$fields = $q->fetchAll(PDO::FETCH_OBJ);
$fieldsArr = array();
foreach($fields as $row){
$fieldsArr[] = $row->Field;
}
$db->query("TRUNCATE utf_{$table}");
$q = $db->query("SELECT * FROM $table");
$data = $q->fetchAll(PDO::FETCH_OBJ);
$db->query("SET NAMES UTF8");
foreach($data as $row){
$values = array();
foreach($fields as $field){
$fname = $field->Field;
$val = $row->$fname;
$val = iconv('ISO-8859-2','UTF-8', $val);
$values[] = "'{$val}'";
}
$sql = "INSERT INTO utf_{$table} (".implode(',', $fieldsArr).") VALUES (".implode(',', $values).")";
$st = $db->query($sql);
}
Does this script seem right for changing the encoding of data within the database to UTF-8?
|
|
|
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88
|
|
Joined: Dec 2003
Posts: 6,649 Likes: 88 |
This is a little above my head. But there is a utility for mysql to change the encoding. At least in phpmyadmin. And the script provided seems to only address a few tables. Where ubb has around 65 tables. Then you still need to edit the scripts to write new data to the new format.
Blue Man Group There is no such thing as stupid questions. Just stupid answers
|
|
|
|
1 members (Havenofsobriety),
176
guests, and
163
robots. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
|