Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert file_get_contents() result to valid utf8 #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ http://simplehtmldom.sourceforge.net/
Install
-------

composer.phar require
- package name: "sunra/php-simple-html-dom-parser": "dev-master"

composer.phar
```json
"require": {
"sunra/php-simple-html-dom-parser": "v1.5.0"
}
```

Usage
-----
Expand Down
5 changes: 5 additions & 0 deletions Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ function file_get_html($url, $use_include_path = false, $context=null, $offset =
$contents = file_get_contents($url, $use_include_path, $context, $offset);
// Paperg - use our own mechanism for getting the contents as we want to control the timeout.
//$contents = retrieve_url_contents($url);

//convert contents to utf8
$contents = mb_convert_encoding($contents, 'UTF-8',
mb_detect_encoding($contents, 'UTF-8, ISO-8859-1', true));

if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "sunra/php-simple-html-dom-parser",
"type": "library",
"description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",
"version": "1.5.0",
"description": "Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.",
"keywords": ["html", "dom", "parser"],
"homepage": "https://github.com/sunra/php-simple-html-dom-parser",
"license": "MIT",
Expand Down