txt in UTF-8 format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aetoc
Forum Commoner
Posts: 37
Joined: Tue Jan 31, 2006 2:48 am

txt in UTF-8 format

Post by aetoc »

I create a file with fopen and I want to save it in UTF-8 format.
The creation is made by request from the user.

Can anyone help me?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Write a BOM (Byte-order marker) then the rest of the file. A BOM isn't explicitly required, but is a good idea if the file is to be used with a program that does understand UTF-8. You may need to convert the incoming text to UTF-8, so look at mb_convert_encoding().
Post Reply