Programming Tutorials

(追記) (追記ここまで)

fixEncoding in PHP

By: mrezair in PHP Tutorials on 2011年07月31日 [フレーム]

I found this little function very useful in fixing strings that are not in utf-8 but need be converted .

<?php 
// Fixes the encoding to uf8 
function fixEncoding($in_str) 
{ 
 $cur_encoding = mb_detect_encoding($in_str) ; 
 if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8")) 
 return $in_str; 
 else 
 return utf8_encode($in_str); 
} // fixEncoding 
?>



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /