Advertisement

02.11.2008 at 07:56AM PST, ID: 23153298
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Problem reading UTF8 formatted file

Tags: php, utf8
Trying to read in TSV Unicode file and then insert the data into a MySQL database.  This example is in Mandarin, but we'll be dealing with Turkish, Arabic, Japanese... the whole works. Reading the data out of the file (first var_dump()) appears to show most of the Chinese character symbols, but when getting the contents into the array using fgetcsv(), both the English and the Mandarin get garbled with the <?> character interspersed, and the Chinese characters disappear completely - I've tried using several techniques two of the latest are included in the first 4 lines of the while() loop, and have no discernable effect to readability (although the outputted garbage does change).  Text file attached.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
$row = 0;
        $importdata = Array();
        // Help fgetcsv() to read in UTF8
        setlocale( LC_ALL, 'en_US.UTF-8' );
        $handle = fopen( $_FILES[ "uploadcsv" ][ "tmp_name" ], "r" );
        var_dump( ( fread( $handle, 10000 ) ) );
        while ( ( $data = fgetcsv( $handle, 10000, "    " ) ) !== FALSE )
        {
                $importdata[ $row ][ "englishlanguagename" ] = 
mb_convert_encoding( $data[ 0 ], "UTF-8", "auto" );
                $importdata[ $row ][ "nativelanguagename" ] = 
mb_convert_encoding( $data[ 1 ], "UTF-8", "auto" );
                $importdata[ $row ][ "englishcategoryname" ] = 
utf8_encode( $data[ 2 ] );
                $importdata[ $row ][ "nativecategoryname" ] = 
utf8_encode( $data[ 3 ] );
                $importdata[ $row ][ "englishsubcategoryname" ] = $data[ 
4 ];
                $importdata[ $row ][ "nativesubcategoryname" ] = $data[ 5 ];
                $importdata[ $row ][ "englishphrase" ] = $data[ 6 ];
                $importdata[ $row ][ "nativephrase" ] = $data[ 7 ];
                $importdata[ $row ][ "audiofile" ] = $data[ 8 ];
                $row++;
        }
        fclose( $handle );
        unlink( $_FILES[ "uploadcsv" ][ "tmp_name" ] );
 
        echo "<pre>"; var_dump( $importdata ); echo "</pre>";
Attachments:
 
html output generated
 
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: grblades
Solution Provided By: grblades
Participating Experts: 1
Solution Grade: A
Views: 148
Translate:
Loading Advertisement...
02.11.2008 at 08:24AM PST, ID: 20867595

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.11.2008 at 08:29AM PST, ID: 20867633

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.11.2008 at 10:22PM PST, ID: 20872822

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 12:54AM PST, ID: 20873279

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 02:27AM PST, ID: 20873691

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 03:07AM PST, ID: 20873868

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.12.2008 at 09:50AM PST, ID: 20877023

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_EXPERT_20070906