A bug of iconv ?

Discussion in 'PHP' started by nat000, Jul 19, 2011.

  1. #1
    Hi all,

    iconv("UTF-8","UTF-8//IGNORE",$txt) returns

    Unknown error type: [8] iconv() [function.iconv]: Detected an illegal character in input string...
    in line XX of file XX.php

    Why ? //IGNORE should take care of that, shouldn't it?
    :confused:
     
    Last edited: Jul 19, 2011
    nat000, Jul 19, 2011 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    NO! //IGNORE can only be used in PHP itself and not in functions, classes or other methods! :)

    if () { // IGNORE is ok
    if (function("//IGNORE")) { is NOT ok coz its seen as text!

    :)
     
    EricBruggema, Jul 23, 2011 IP
  3. nat000

    nat000 Member

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    So we can't use IGNORE with iconv?

    Is there a way to fix corrupted utf-8 text without warnings ? (simply ignoring invalid characters ) ?


    Also , there are examples of using iconv with IGNORE at php.net :
    http://www.php.net/manual/en/function.iconv.php

    And, on my local system, it does work (I have libiconv implementation)

    On production server, there is glibc implementation and doesn't work
     
    nat000, Jul 29, 2011 IP
  4. nat000

    nat000 Member

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    up
    could anybody suggest something?
     
    nat000, Aug 9, 2011 IP