Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | /* -( Configuring Storage )------------------------------------------------ */ | ||||
protected function detectEncodingForStorage($string) { | protected function detectEncodingForStorage($string) { | ||||
return phutil_is_utf8($string) ? 'utf8' : null; | return phutil_is_utf8($string) ? 'utf8' : null; | ||||
} | } | ||||
protected function getUTF8StringFromStorage($string, $encoding) { | protected function getUTF8StringFromStorage($string, $encoding) { | ||||
if ($encoding == 'utf8') { | if ($encoding == 'utf8') { | ||||
return $string; | return $string; | ||||
} | } | ||||
if (function_exists('mb_detect_encoding')) { | |||||
if (strlen($encoding)) { | |||||
$try_encodings = array( | |||||
$encoding, | |||||
); | |||||
} else { | |||||
// TODO: This is pretty much a guess, and probably needs to be | |||||
// configurable in the long run. | |||||
$try_encodings = array( | |||||
'JIS', | |||||
'EUC-JP', | |||||
'SJIS', | |||||
'ISO-8859-1', | |||||
); | |||||
} | |||||
$guess = mb_detect_encoding($string, $try_encodings); | |||||
if ($guess) { | |||||
return mb_convert_encoding($string, 'UTF-8', $guess); | |||||
} | |||||
} | |||||
return phutil_utf8ize($string); | return phutil_utf8ize($string); | ||||
} | } | ||||
public function delete() { | public function delete() { | ||||
// TODO: We should make some reasonable effort to destroy related | // TODO: We should make some reasonable effort to destroy related | ||||
// infrastructure objects here, like edges, transactions, custom field | // infrastructure objects here, like edges, transactions, custom field | ||||
// storage, flags, Phrequent tracking, tokens, etc. This doesn't need to | // storage, flags, Phrequent tracking, tokens, etc. This doesn't need to | ||||
// be exhaustive, but we can get a lot of it pretty easily. | // be exhaustive, but we can get a lot of it pretty easily. | ||||
return parent::delete(); | return parent::delete(); | ||||
} | } | ||||
} | } |