Subversion Repositories oidinfo_api

Rev

Rev 15 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15 Rev 25
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * XML Encoding Utilities
4
 * XML Encoding Utilities
5
 * Copyright 2011-2020 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2011-2021 Daniel Marschall, ViaThinkSoft
6
 * Version 1.7.2 (2020-12-06)
6
 * Version 1.8 (2021-11-24)
7
 *
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
10
 * You may obtain a copy of the License at
11
 *
11
 *
Line 180... Line 180...
180
        }
180
        }
181
}
181
}
182
 
182
 
183
if (!function_exists('mb_htmlentities')) {
183
if (!function_exists('mb_htmlentities')) {
184
        // https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
184
        // https://riptutorial.com/php/example/15633/converting-unicode-characters-to-their-numeric-value-and-or-html-entities-using-php
-
 
185
        // modified
185
        function mb_htmlentities($string, $hex = true, $encoding = 'UTF-8') {
186
        function mb_htmlentities($string, $hex = true, $encoding = 'UTF-8') {
186
                return preg_replace_callback('/[\x{80}-\x{10FFFF}]/u', function ($match) use ($hex) {
187
                return preg_replace_callback('/[\x{80}-\x{10FFFF}]/u', function ($match) use ($hex, $encoding) {
-
 
188
                        $ord = (strtoupper($encoding) == 'UTF-8') ? ordUTF8($match[0]) : mb_ord($match[0]);
187
                        return sprintf($hex ? '&#x%X;' : '&#%d;', mb_ord($match[0]));
189
                        return sprintf($hex ? '&#x%X;' : '&#%d;', $ord);
188
                }, $string);
190
                }, $string);
189
        }
191
        }
190
}
192
}