douphp Posted October 17, 2007 Share Posted October 17, 2007 Hello, I need a little help with exporting data from a database that contains language packages. To explain in short I have a small PHP script that is multilingual and all the phrases are stored in the database. It currently can export the phrases for a specific language package and it can also import the exported data. So it allows the usage of other language packages in the future. It works great with the default language package I have setup, which is English; however I am having problems with other languages such as Polish, Greek, Russian etc... When I export the data and then try to import the data using my script all the special characters turn into question marks. Since the exported data is in a flat PHP file I use PHP fwrite to write to the file. I tried to use PHP's utf8_encode, however that did not do much help. I also tested to change the collation of the database, which also did not help. So I am rather lost as to how scripts like vBulletin can export language packages and then import it, while dealing with character issues. Any help would be appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
NixNod Posted October 17, 2007 Share Posted October 17, 2007 You must set the encoding of the database as UTF-8 and the database fields as UTF-8_General_CI Your PHP page you must save as UTF-8, and in the HTML Header, you must set the content as UTF-8. It should work. But for a test, you can just set the page character manually by pressing in your browser: View->Character Encoding->Unicode (UTF- or whatever encoding you will use. Quote Link to comment Share on other sites More sharing options...
douphp Posted October 17, 2007 Author Share Posted October 17, 2007 Thanks for the reply. I tested to change the collations (encoding) for the database and database fields. I tried "UTF-8_General_CI" amongst others. I also have it set in the HTML header as UTF-8. When printing the exported data I can see the correct data, however when saving it to a PHP flat file this is what is causing me problems. The reasons I am saving it to a PHP flat file is so I can import the data at a later time. Quote Link to comment Share on other sites More sharing options...
douphp Posted October 18, 2007 Author Share Posted October 18, 2007 I believe I got it working. I had to add this at the top of my script: header('Content-Type: text/html; charset=UTF-8'); Funny thing is it worked fine on one server without it, while on another server it did not which was the one I was developing on. In any case having that in the script helped me to get it working on both servers and for different languages. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.