From e6386db06c1aae42f7df0727420c8c529c7f29ab Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 16 Sep 2018 00:43:42 +0200 Subject: Fixed encoding issue :sparkles: --- crawler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crawler.php b/crawler.php index dd8aec1..1c1f562 100644 --- a/crawler.php +++ b/crawler.php @@ -186,8 +186,8 @@ function saveData($urlInfo) print "\e[96mFinished previous url - crawling: " . $currentUrl . "\n"; - $title = $urlInfo['title'] ?? ''; - $description = $urlInfo['description'] ?? ''; + $title = mb_convert_encoding($urlInfo['title'] ?? '', 'Windows-1252', 'UTF-8'); + $description = mb_convert_encoding($urlInfo['description'] ?? '', 'Windows-1252', 'UTF-8'); $language = $urlInfo['language'] ?? 'en'; $hash = md5($currentUrl); @@ -212,7 +212,7 @@ function alreadyCrawled($url) function initDbConnection() { global $servername, $dbname, $username, $password; - $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); + $conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $conn; } \ No newline at end of file -- cgit v1.2.3