source: trunk/client/inc/hpdf5/spipu/html2pdf/src/Parsing/TextParser.php

Last change on this file was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 1.0 KB
Line 
1<?php
2/**
3 * Html2Pdf Library - parsing Html class
4 *
5 * HTML => PDF converter
6 * distributed under the OSL-3.0 License
7 *
8 * @package Html2pdf
9 * @author Laurent MINGUET <webmaster@html2pdf.fr>
10 * @copyright 2017 Laurent MINGUET
11 */
12namespace Spipu\Html2Pdf\Parsing;
13
14/**
15 * Class TextParser
16 */
17class TextParser
18{
19 /**
20 * @var string
21 */
22 private $encoding;
23
24 /**
25 * @param string $encoding
26 */
27 public function __construct($encoding = 'UTF-8')
28 {
29 $this->encoding = $encoding;
30 }
31
32 /**
33 * prepare the text
34 *
35 * @param string $txt
36 * @param boolean $spaces true => replace multiple space+\t+\r+\n by a single space
37 * @return string txt
38 * @access protected
39 */
40 public function prepareTxt($txt, $spaces = true)
41 {
42 if ($spaces) {
43 $txt = preg_replace('/\s+/isu', ' ', $txt);
44 }
45 $txt = str_replace('&euro;', '€', $txt);
46 $txt = html_entity_decode($txt, ENT_QUOTES, $this->encoding);
47 return $txt;
48 }
49}
Note: See TracBrowser for help on using the repository browser.