random1 Posted July 3, 2008 Share Posted July 3, 2008 How can you save the following data as a file using utf-8 file encoding programmatically. e.g. <?php $filedata = "some utf-8 date goes here"; $outfile = "file.php"; ?> How can you do this without saving a BOM (byte order mark). Quote Link to comment https://forums.phpfreaks.com/topic/113029-saving-files-with-utf-8-file-encoding/ Share on other sites More sharing options...
.josh Posted July 3, 2008 Share Posted July 3, 2008 fwrite() Quote Link to comment https://forums.phpfreaks.com/topic/113029-saving-files-with-utf-8-file-encoding/#findComment-580647 Share on other sites More sharing options...
random1 Posted July 3, 2008 Author Share Posted July 3, 2008 My Code is: <?php $myString = "Test with accents éèàç На берегу пустынных волн து எங்கும் கா शक्नोम्यत्तुम् । زه شيشه خوړلې"; $fh=fopen('test.xml',"w"); fwrite($fh,utf8_encode($myString)); fclose($fh); ?> Output from that is: éèà ç Ðа берегу пуÑтынных волн த௠எஙà¯à®•à¯à®®à¯ கா शकà¥à¤¨à¥‹à¤®à¥à¤¯à¤¤à¥à¤¤à¥à¤®à¥ । زه شيشه Ø®ÙˆÚ“Ù„Û but is saved as utf-8. Quote Link to comment https://forums.phpfreaks.com/topic/113029-saving-files-with-utf-8-file-encoding/#findComment-580663 Share on other sites More sharing options...
bluejay002 Posted July 3, 2008 Share Posted July 3, 2008 just a set of questions: 1. what language are you working on? 2. since the string you place there were static, what encoding was used to save that php script that has that string? 3. if it is encoded from a different charset, try using mb_convert_encoding(). maybe along the way you might find an answer here or else, please post your answer, I'll try my best to help . Quote Link to comment https://forums.phpfreaks.com/topic/113029-saving-files-with-utf-8-file-encoding/#findComment-580671 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.