Skip to content

Commit

Permalink
change charset encoding function
Browse files Browse the repository at this point in the history
  • Loading branch information
kirrie committed Aug 17, 2016
1 parent be6be95 commit 7f7773f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions HappySF/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ public function setURL($url) {

private function convertCharacterEncodingToUTF8($text) {
$text = !is_string($text) ? '' : $text;

return (empty($text) ? $text : iconv('EUC-KR', 'UTF-8//IGNORE', $text));

if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($text, 'UTF-8', 'EUC-KR');
} else {
return (empty($text) ? $text : iconv('EUC-KR', 'UTF-8//IGNORE', $text));
}
}

public function setTitle($title) {
Expand Down
6 changes: 6 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ function getConfig() {
->setContentType('text/html; charset=utf-8')
->setStatusCode($e->getResponse()->getStatusCode())
->write($e->getMessage());
} catch(Exception $e) {
$output
->unsetCacheHeader()
->setContentType('text/html; charset=utf-8')
->setStatusCode(500)
->write('Message: ' . $e->getMessage() . '<br />Stacks:<br />' . str_replace("\n", '<br />', $e->getTraceAsString()));
}

// flush
Expand Down

0 comments on commit 7f7773f

Please sign in to comment.