Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5976124
DOMUtils.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1014 B
Referenced Files
None
Subscribers
None
DOMUtils.php
View Options
<?php
namespace
Wikimedia\RemexHtml\DOM
;
use
Wikimedia\RemexHtml\HTMLData
;
class
DOMUtils
{
/**
* Replace unsupported characters with a code of the form U123456.
*
* @param string $name
* @return string
*/
public
static
function
coerceName
(
$name
)
{
$coercedName
=
mb_encode_numericentity
(
mb_substr
(
$name
,
0
,
1
,
'UTF-8'
),
HTMLData
::
$nameStartCharConvTable
,
'UTF-8'
,
true
)
.
mb_encode_numericentity
(
mb_substr
(
$name
,
1
,
null
,
'UTF-8'
),
HTMLData
::
$nameCharConvTable
,
'UTF-8'
,
true
);
$coercedName
=
preg_replace_callback
(
'/&#x([0-9A-F]*);/'
,
static
function
(
$m
)
{
return
'U'
.
str_pad
(
$m
[
1
],
6
,
'0'
,
STR_PAD_LEFT
);
},
$coercedName
);
return
$coercedName
;
}
/**
* Invert the encoding produced by coerceName()
*
* @param string $name
* @return string
*/
public
static
function
uncoerceName
(
$name
)
{
return
mb_decode_numericentity
(
preg_replace
(
'/U([0-9A-F]{6})/'
,
'&#x
\1
;'
,
$name
),
[
0
,
0x10ffff
,
0
,
0xffffff
],
'UTF-8'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 18:52 (1 d, 20 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
df/18/4ca6cb1945622e189d72ebdfe8c4
Default Alt Text
DOMUtils.php (1014 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment