Line | |
---|
1 | <?php
|
---|
2 | /**
|
---|
3 | * This class provides methods to detect and convert binary data from an to
|
---|
4 | * hexadecimal strings.
|
---|
5 | *
|
---|
6 | * PHP versions 4 and 5
|
---|
7 | *
|
---|
8 | * LICENSE: This source file is subject to version 2.02 of the PHP license,
|
---|
9 | * that is bundled with this package in the file LICENSE, and is available at
|
---|
10 | * through the world-wide-web at http://www.php.net/license/2_02.txt. If you
|
---|
11 | * did not receive a copy of the PHP license and are unable to obtain it
|
---|
12 | * through the world-wide-web, please send a note to license@php.net so we can
|
---|
13 | * mail you a copy immediately.
|
---|
14 | *
|
---|
15 | * @category Web Services
|
---|
16 | * @package SOAP
|
---|
17 | * @author Dietrich Ayala <dietrich@ganx4.com> Original Author
|
---|
18 | * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more
|
---|
19 | * @copyright 2003-2007 The PHP Group
|
---|
20 | * @license http://www.php.net/license/2_02.txt PHP License 2.02
|
---|
21 | * @link http://pear.php.net/package/SOAP
|
---|
22 | */
|
---|
23 | class SOAP_Type_hexBinary {
|
---|
24 |
|
---|
25 | function to_bin($value)
|
---|
26 | {
|
---|
27 | return pack('H' . strlen($value), $value);
|
---|
28 | }
|
---|
29 |
|
---|
30 | function to_hex($value)
|
---|
31 | {
|
---|
32 | return bin2hex($value);
|
---|
33 | }
|
---|
34 |
|
---|
35 | function is_hexbin($value)
|
---|
36 | {
|
---|
37 | // First see if there are any invalid chars.
|
---|
38 | if (!strlen($value) || preg_match('/[^A-Fa-f0-9]/', $value)) {
|
---|
39 | return false;
|
---|
40 | }
|
---|
41 |
|
---|
42 | return strcasecmp($value, SOAP_Type_hexBinary::to_hex(SOAP_Type_hexBinary::to_bin($value))) == 0;
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.