reading unicode tab delimited text file in php

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
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

reading unicode tab delimited text file in php

Post by jimthunderbird »

Hi All,
Recently I'm involved with a task to read a tab delimited text file in unicode and then convert them into a series of sql insert statements and then insert to mysql db.

I've successfully done the similar thing in the past with the text in ASCII using php's fgetcsv, but this time it does not work for this unicode file. In the file it has some funny characters like '®'.

Anyone had some hints on this?

Thank you very much.

Best Regards,
jim
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

explode() on tabs (\t) ?

edit| or do you mean the characters are giving you problems? you can run html_entities() on it with the charset set
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

Post by jimthunderbird »

Hi,
I think my problem nails down to these two lines of code, it doesn't seem to work:

Code: Select all

$content = str_replace("®","®","®123");
     print $content;
Do you have any hints on it?

Thanks.

Best Regards,
Jim
Post Reply