tapius1 Posted January 5, 2011 Share Posted January 5, 2011 I have a HUGE issues, im reading in a .txt file which contains foreign letters like, " ö " however, when i use fread, $fileOfRecords = fread($handle, filesize($filename)); and insert into the MSSQL Database, (The database is setup to handle encoding types with such character sets) When reviewing the text in the tables, such characters like ö turn into "ö" making the text in the tables garbage. My question is - how can i make sure that when I read these files and do my table inserts, that the correct character is being inserted. I know for a fact that the Database can handle these characters as Ive just done a replace of ö for ö, and ö stayed in the tables, so it is a matter of my php script. Any help would be greatly appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/223423-fread-with-encoding-type/ Share on other sites More sharing options...
johnny86 Posted January 5, 2011 Share Posted January 5, 2011 You have to know what character encoding is used in the txt file you are reading and then convert it to the encoding you want. There are PHP features that you might find helpful doing this. http://fi.php.net/iconv http://fi.php.net/utf8_encode http://fi.php.net/utf8_decode And everything related to those functions. (Including user comments, there are some handy functions submitted) Link to comment https://forums.phpfreaks.com/topic/223423-fread-with-encoding-type/#findComment-1154976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.