Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
2 registered (Gizmo, SteveS), 38 Guests and 14 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 06/07/07
Posts: 4
Top Posters (30 Days)
Ruben 50
DennyP 24
Gizmo 23
Dunny 15
SteveS 13
AllenAyres 12
dbremer 10
SD 10
drkknght00 9
doug 8
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Topic Options
#247148 - 12/07/11 01:22 PM Changing the character encoding of all posts in database
Conrad Offline
addict
Registered: 08/04/04
Posts: 425
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?
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#247162 - 12/07/11 04:25 PM Re: Changing the character encoding of all posts in database [Re: Conrad]
Ruben Offline

Registered: 12/20/03
Posts: 4424
Loc: Lutz,FL
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
Top
#247220 - 12/11/11 02:04 PM Re: Changing the character encoding of all posts in database [Re: Conrad]
Conrad Offline
addict
Registered: 08/04/04
Posts: 425
Is the change done by just altering the encoding settings for the database in phpMyAdmin and then editing generic.php?
Top
#247222 - 12/11/11 04:14 PM Re: Changing the character encoding of all posts in database [Re: Conrad]
Ruben Offline

Registered: 12/20/03
Posts: 4424
Loc: Lutz,FL
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
Top
#247224 - 12/11/11 04:32 PM Re: Changing the character encoding of all posts in database [Re: Conrad]
Gizmo Online   cat

Registered: 06/05/06
Posts: 14995
Loc: Portland, OR; USA
If I recall you just need to update the "charset" value in the general language file to read "UTF-8".
_________________________
Forums: UGN Security & VNC Web Design & Development
UBB.Threads: UBB.Wiki, My UBBSkins, UBB.Sitemaps
Longtime UBB Supporter, UBB Beta Tester & Resident Post-A-Holic.
UBB Modifications, Styling, Coding Services, Disaster Recovery, and more!
Top
#247237 - 12/13/11 11:21 AM Re: Changing the character encoding of all posts in database [Re: Gizmo]
Conrad Offline
addict
Registered: 08/04/04
Posts: 425
Originally Posted By: Gizmo
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.
Top
#247238 - 12/13/11 01:22 PM Re: Changing the character encoding of all posts in database [Re: Conrad]
Ruben Offline

Registered: 12/20/03
Posts: 4424
Loc: Lutz,FL
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:
Quote:
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.

Quote:
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
Top
#247473 - 12/27/11 12:45 PM Re: Changing the character encoding of all posts in database [Re: Ruben]
Conrad Offline
addict
Registered: 08/04/04
Posts: 425
Code:
<?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?
Top
#247511 - 12/27/11 05:46 PM Re: Changing the character encoding of all posts in database [Re: Conrad]
Ruben Offline

Registered: 12/20/03
Posts: 4424
Loc: Lutz,FL
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
Top



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Temporary Password email not being received
by
05/24/12 10:02 PM
Ability to "like" individual posts (not Facebook "likes)
by doug
05/23/12 09:03 AM
Island Permissions
by ThreadsUser
05/22/12 03:03 PM
streaming video
by prkrgrp
05/20/12 07:02 PM
New Posts Corrupted? Can someone help?
by PianoWorld
05/19/12 09:41 AM
Forum Stats
10492 Members
36 Forums
33842 Topics
181709 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image