Skip to content

Commit 209e88d

Browse files
committed
minor #8471 Explained the DomCrawler charset guessing mechanism (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #8471). Discussion ---------- Explained the DomCrawler charset guessing mechanism This fixes #8449. Commits ------- 78a49a9 Explained the DomCrawler charset guessing mechanism
2 parents 159459b + 78a49a9 commit 209e88d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

components/dom_crawler.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,19 @@ The crawler supports multiple ways of adding the content::
237237

238238
.. note::
239239

240-
When dealing with character sets other than ISO-8859-1, always add HTML
241-
content using the :method:`Symfony\\Component\\DomCrawler\\Crawler::addHtmlContent`
242-
method where you can specify the second parameter to be your target character
243-
set.
240+
The :method:`Symfony\\Component\\DomCrawler\\Crawler::addHtmlContent` and
241+
:method:`Symfony\\Component\\DomCrawler\\Crawler::addXmlContent` methods
242+
default to UTF-8 encoding but you can change this behavior with their second
243+
optional argument.
244+
245+
The :method:`Symfony\\Component\\DomCrawler\\Crawler::addContent` method
246+
guesses the best charset according to the given contents and defaults to
247+
``ISO-8859-1`` in case no charset can be guessed.
248+
249+
.. versionadded:: 3.4
250+
The charset guessing mechanism of the ``addContent()`` method was
251+
introduced in Symfony 3.4. In previous Symfony versions, ``ISO-8859-1``
252+
charset was always used.
244253

245254
As the Crawler's implementation is based on the DOM extension, it is also able
246255
to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`
@@ -397,13 +406,13 @@ a :class:`Symfony\\Component\\DomCrawler\\Form` object that represents the
397406
form that the button lives in::
398407

399408
// button example: <button id="my-super-button" type="submit">My super button</button>
400-
409+
401410
// you can get button by its label
402411
$form = $crawler->selectButton('My super button')->form();
403-
412+
404413
// or by button id (#my-super-button) if the button doesn't have a label
405414
$form = $crawler->selectButton('my-super-button')->form();
406-
415+
407416
// or you can filter the whole form, for example a form has a class attribute: <form class="form-vertical" method="POST">
408417
$crawler->filter('.form-vertical')->form();
409418

0 commit comments

Comments
 (0)