Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

[resources.invisionpower.com - pliki] Developer Articles > Migrating to UTF-8


Rekomendowane odpowiedzi

  • Manager

Right from the outset, I want to make it clear that I make no warranty or promises for the information in this post. I'm not an expert. It is merely an outline of the steps I have made to bring my server and IPB installation up to UTF-8 spec in the hope some other IPS customers will find it useful.

Note also that this does *NOT* provide instructions to convert existing data in posts to UTF-8, however, any latin1 data already in your forum should work fine after making the changes listed below. I have not converted my existing data because I'm not too concerned that some old posts might have some scrambled foreign text, as long as the vast majority of latin1 still displays OK (as it does)... Conversion of existing data is a huge and dangerous task that most people won't need to do anyway, unless their primary board language is in a complex Asian script, like Japanese for example.

About my decision to make the change:

I'm am an IPB customer since the 2.0 days and my board was still in latin1. My board is primarily English language but it is based in Singapore and often addresses language queries from members, which are invariably in complex Asian scrips, primarily Thai, Japanese and Chinese, so I decided to make the switch to UTF-8 in order to guarantee everything functions correctly and future proof the database. Collation data was also missing from my database. More on that later...

Only you can decide if you should make the change. If you're absolutely certain that your board will never have foreign languages posted, you're probably better off staying as you are... but I personally think that if you're board ever gets foreign scripts posted, it's prudent to make the change sooner rather than later as it will only get more painful the longer you leave it.

There are lots and lots of UTF-8 flavours and obviously you choose the right one for your language. However, nearly everyone will be choosing 'UTF8_general_ci' or 'UTF8_unicode_ci'... What's the difference? Not much, but the latter had additional support for certain types of languages and although it is marginally slower, I chose UTF8_unicode_ci because of the complexity of the scripts sometimes posted on my forum. All of the instructions below reflect that, so adjust accordingly for your own installation.

Some of the measures listed below will require you to have root access to your server, or a host that's willing to assist you make the changes (probably not going to happen).

REMEMBER: BACKUP BACKUP BACKUP!

So, now that's out of the way, lets look at what I did...

-----------------------------

I think it important to get the native charset of your server set up accordingly. If you go to your ACP --> Support --> SQL System Vars you will see a list of various charsets running on your server. The ones you are most interested in are collation_server and character_set_server. Once you have set these, the others should inherit. In order to set these to UTF-8, open up your /etc/my.cnf file and add the following three lines under [mysqld]...

collation_server=utf8_unicode_ci

character_set_server=utf8

skip-character-set-client-handshake

Save and restart SQL. Now you need to open up your php.ini file and ensure the following is in place...

default_charset = "UTF-8"

Save and restart Apache.

So now we've got the server talkin' in in UTF-8

Now onto the database itself. If you're a legacy customer, your charset will almost certainly be latin1_swedish yadda yadda. You will have lines throughout your database that look like this...

) ENGINE=MyISAM AUTO_INCREMENT=2139 DEFAULT CHARSET=latin1;

... and are missing a 'collation' entry. There are a number of ways you can correct this, you could for example open up phpmyadmin and individually change each table/column/row but you'd be there all night. You could also automate it and so a search/replace via a terminal... in my case, I chose what I considered to be the safe way by downloading the database to my local machine, opened it up in a text editor and did a find/replace. After I'd finished, the above line now looks like this (for every instance (but DON'T touch the increment value, make sure your search/replace leaves that alone))...

) ENGINE=MyISAM AUTO_INCREMENT=2137 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

Save. Prepare to import the database back to your live board.

The following is important (so that any tables created by IPB in the future are in UTF-8)... In your phpmyadmin, ensure that the MySQL connection collation is set to 'UTF8_unicode_ci'.

Add the following line to your conf_global (or if it's there already, change it to UTF-8)...

$INFO['sql_charset'] = 'utf8';

Now import your database and bring it online to your live board. Immediately, go to ACP --> System Settings --> Server Envoronment and set the Document Character Set to UTF-8

You're done... ไม่เป็นไร Wyświetl pełny artykuł

intermedia - profesjonalne rozwiązania Invision Power Board

---

Chcesz uzyskać szybko i sprawnie pomoc? Uzupełnij wersję i adres w profilu.

Odnośnik do komentarza
Udostępnij na innych stronach

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.