mPDF Manual – mPDF Utilities

strcode2utf()

(mPDF ≥1.0 && < 7.0)

strcode2utf – Convert HTML numerical entities to UTF-8 encoded string

Description

string strcode2utf ( string $text [, boolean $low ])

Returns a UTF-8 encoded string.

Parameters

$text

The input string, containing HTML numerical entities e.g. &#8123; or &#x2022;

$low

Specifies whether to convert HTML numerical entities of ASCII characters (< 128).

Default: true

Values

  • true: Convert all HTML numerical entities to UTF-8 characters
  • false: Only convert characters above codepoint 127

Return value

Returns a UTF-8 encoded string.

Changelog

Version Description
1.0 Function was added.
7.0 Function was removed in favor of \Mpdf\Utils\UtfString::strcode2utf static class method

Examples

<?php

$mpdf = new \Mpdf\Mpdf();

$mpdf->showWatermark = true;

$wm = \Mpdf\Utils\UtfString::strcode2utf("&#1575;&#1610;&#1604;&#1575;&#1578; &#1601;&#1610;&#1605;&#1575;
    &#1575;&#1610;&#1604;&#1575;&#1578; &#1601;&#1610;&#1605;&#1575;");

$mpdf->SetWatermarkText($wm);
$mpdf->WriteHTML('Hello World');

See Also

Fork me on GitHub