[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP load excel spreadsheet - invalid character ??

Posted on 2007-08-07
2
Medium Priority
?
500 Views
Last Modified: 2008-01-09
I am using reader.php to upload a spreadsheet that is then loaded in  to MySQL.

I am getting the following error regarding invalid characters.

Notice: iconv(): Detected illegal character in input string in /var/www/html/admin/readers/Excel/reader.php on line 797

This seems to be the offending function:

    function _encodeUTF16($string){
          $result = $string;
        if ($this->_defaultEncoding){
              switch ($this->_encoderFunction){
                    case 'iconv' :       $result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
                                            break;
                    case 'mb_convert_encoding' :       $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' );
                                            break;
              }
        }
        return $result;
    }

Any ideas?

Thanks.
0
Comment
Question by:Luv2Muff
2 Comments
 
LVL 9

Accepted Solution

by:
blue_hunter earned 2000 total points
ID: 19648370
   function _encodeUTF16($string){
          $result = str_replace(array("\r","\n"), array("",""), $string);   // try modify this line
        if ($this->_defaultEncoding){
              switch ($this->_encoderFunction){
                    case 'iconv' :       $result = iconv('UTF-16LE', $this->_defaultEncoding, $string);
                                            break;
                    case 'mb_convert_encoding' :       $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' );
                                            break;
              }
        }
        return $result;
    }
0
 

Author Comment

by:Luv2Muff
ID: 19652481
Hi blue_hunter,

Thanks for you suggestion. I am just waiting for a quite time on the server to try this out, before getting back to you. Apologies for the delay.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month18 days, 4 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question