Jump to content

fread with encoding type?


tapius1

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.