bug-gnu-libiconv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnu-libiconv] libiconv problem with non-breaking space


From: Bruno Haible
Subject: Re: [bug-gnu-libiconv] libiconv problem with non-breaking space
Date: Thu, 15 Oct 2009 10:49:09 +0200
User-agent: KMail/1.9.9

Hi,

Boris Burtin wrote:
> I'm calling iconv from a PHP script ...

I cannot really speak about the iconv wrapper in PHP. It's likely a thin
wrapper that only does conversions between PHP data types and C data types.
So let me try to answer nevertheless:

> I'm having a problem with converting UTF-8 text that contains a non-breaking
> space character (unicode 00a0) to iso-8859-1. ... with this line of code:  
> 
> $text = iconv("UTF-8", "iso-8859-1//IGNORE", $text); 
> 
> I thought that the //IGNORE flag would cause iconv to ignore characters that
> it can't handle, 

Yes, the //IGNORE suffix in the target encoding specifies - for GNU libc and
GNU libiconv - that characters that cannot be represented in the target
character set will be silently discarded.

> but instead I get this error:  
> 
> Error 8: iconv() [<a href='function.iconv'>function.iconv</a>]: Detected an 
> illegal character in input string 

The character U+00A0 is part of ISO-8859-1.

Does the error occur independently of the //IGNORE suffix? If yes, then your
problem is not with the character U+00A0. But maybe the input is not in UTF-8
encoding?

> Is this a bug in libiconv, or is there something I need to do to massage
> the string before converting it?  

A priori your use of the PHP iconv function looks fine.

Before you can conclude that you have a bug in libiconv, you have to do 3 steps:

Step 1: Provide a reproducible example in the PHP environment.

Step 2: Translate the reproducible example to C language, and verify it fails
in C as well.

Step 3: Using "ldd", verify that your executable from step 2 is linked against
libiconv.so.

If you cannot reproduce in C (step 2), it's a bug in PHP or your PHP 
environment.

If step 3 shows that GNU libiconv is not in use, then the bug report should go
to the implementors of your system's iconv() function.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]