简体   繁体   中英

PHP: simplexlsx Parser specialchars

hope someone can help me out.

Im using simplexlsx ( http://www.phpclasses.org/package/6279-PHP-Parse-and-retrieve-data-from-Excel-XLS-files.html ) to read out my Excel files and display them/write them into my DB.

Now i have the problem that the class wont parse specialchars like : "Ä, Ü, Ö, ß..." correct i tryed to write a function to fix it, but it wont work.

Hope some of you guys could help me.

Thx so far xQp

// Try

function unhtmlspecialchars( $string ){    
  $string = str_replace ( '&', '&', $string );    
  $string = str_replace ( ''', '\'', $string );    
  $string = str_replace ( '"', '"', $string );    
  $string = str_replace ( '&lt;', '<', $string );    
  $string = str_replace ( '&gt;', '>', $string );    
  $string = str_replace ( '&uuml;', 'ü', $string );    
  $string = str_replace ( '&Uuml;', 'Ü', $string );    
  $string = str_replace ( '&auml;', 'ä', $string );    
  $string = str_replace ( '&Auml;', 'Ä', $string );    
  $string = str_replace ( '&ouml;', 'ö', $string );    
  $string = str_replace ( '&Ouml;', 'Ö', $string );  
  return $string;
}

tryed to get call that function within the simplexlsx.class before return the $value

// edit 2 my try was the to add the function unhtmlspecialchars to simplexlsx.class and call it at the end of the "function value()" before returning the value like this just to test it...

  $value2 = $this->unhtmlspecialchars($value);

        return $value2 ;

The solution (as stated by the OP in the comments) is to use

utf8_decode($value);

to restore the special chars in the output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM