iconv_substr problem

Topics: Developer Forum, User Forum
Nov 2, 2009 at 1:06 AM

Hi,   I tested export to excel and have problem as follows>

If export in UTF 8 string from mysql with strlen 1 (f.e. char A ), resp. chars ž , š....etc (strlen 2)

there is an error in php excel:

Notice: iconv_substr()..Unknown error (0)..../String.php on line 317

I think there is a problem with php iconv_substr function>

generates folowing error:
Notice: iconv_substr() [function.iconv-substr]: Unknown error (0) in [...]

Can you please help me best way hot to solve it?

i changed code in  function Substring


$string = iconv_substr($pValue, $pStart, $pLength, 'UTF-8');




if (strlen($pValue)<=2) {
            } else {
                $string = iconv_substr($pValue, $pStart, $pLength, 'UTF-8');

return $string;

Iam not sure it is good idea, can somebody help me what is the best way how to fix it?

Many thanks for help in advance


Nov 2, 2009 at 12:48 PM

Question 1:

Is it this bug?


Question 2:

What version of PHP are you using?

Question 3:

What do you when you run this:

var_dump(iconv('UTF-8', 'UTF-16LE', 'x'));

Nov 2, 2009 at 9:12 PM

Hi, how can I fix this problem under php 5.2.0 in php excel? , I think it is a.m. bug


Many thanks ahead for your help.


Nov 3, 2009 at 12:11 AM

Can you try to run the code from Question 3 above and say what you get?

Nov 3, 2009 at 12:37 PM

hi, here is the result       

string(2) "x�"

Nov 4, 2009 at 1:49 AM

I have made a change to detect whether iconv_substr is broken.


Can you try with latest source code from here tomorrow:


Things should work if you have mbstring extension enabled in PHP. Can you check with phpinfo() that you have mbstring enabled?