|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * If you use mbstring.func_overload, or the server you are running on has it enabled, you are in trouble. |
| 4 | + * This class will help overcome that, by provide alternative functions to work around it. |
4 | 5 | * |
5 | | - * To the question "Should I use multi-byte overloading (mbstring.func_overload)?". user 'gphilip' said it well on this |
6 | | - * StackOverflow post: |
7 | | - * http://stackoverflow.com/questions/222630/should-i-use-multi-byte-overloading-mbstring-func-overload |
8 | | - * |
9 | | - * > My answer is: definitely not! |
10 | | - * > |
11 | | - * > The problem is that there is no easy way to "reset" |
12 | | - * > str* functions once they are overloaded. |
13 | | - * > |
14 | | - * > For some time this can work well with your project, |
15 | | - * > but almost surely you will run into an external library |
16 | | - * > that uses string functions to, for example, implement a |
17 | | - * > binary protocol, and they will fail. They will fail and |
18 | | - * > you will spend hours trying to find out why they are |
19 | | - * > failing. |
20 | | - * |
21 | | - * This class is a wrapper for string functions, in cases where the mbstring.func_overload tripe have been enabled. |
22 | | - * Be warned, use this class ONLY if you have to, as it *will* affect performance a bit. For some functions, a lot, |
23 | | - * though that is due to problems in mb_string, not this class. |
24 | | - * Function calls in PHP are fairly expensive on their own, and if func_overload is enabled, it'll use mb_string |
25 | | - * functions exclusively in place of the built-in PHP string, to parse them as 'latin1', which is also expensive, cpu |
26 | | - * wise. |
27 | | - * |
28 | | - * PHP, like Java, have length aware strings, meaning the object header knows how long your string is. They are binary |
29 | | - * safe, and not null (0x00) terminated. |
30 | | - * |
31 | | - * mb_string functions ignore that, and parse the entirety of the string, to figure out what is what. stelen(string) |
32 | | - * simply tells you how many bytes are in it, mb_strlen will parse it, to find multi byte characters, and tell you |
33 | | - * how many characters there are. That is great for handling multi-byte encoded strings correctly, such as UTF-8, it |
34 | | - * sucks for binary data handling, as multi-byte sequences are bound to occur by random chance, in any large enough |
35 | | - * binary data set. |
36 | | - * |
37 | | - * The functions overloaded by mbstring is: |
38 | | - * mbstring.func_overload |
39 | | - * value original function overloaded function |
40 | | - * 1 mail() mb_send_mail() |
41 | | - * |
42 | | - * 2 strlen() mb_strlen() |
43 | | - * 2 strpos() mb_strpos() |
44 | | - * 2 strrpos() mb_strrpos() |
45 | | - * 2 substr() mb_substr() |
46 | | - * 2 strtolower() mb_strtolower() |
47 | | - * 2 strtoupper() mb_strtoupper() |
48 | | - * 2 substr_count() mb_substr_count() |
49 | | - * |
50 | | - * 4 ereg() mb_ereg() |
51 | | - * 4 eregi() mb_eregi() |
52 | | - * 4 ereg_replace() mb_ereg_replace() |
53 | | - * 4 eregi_replace() mb_eregi_replace() |
54 | | - * 4 split() mb_split() |
55 | | - * |
56 | | - * License: GNU LGPL 2.1. |
| 6 | + * see readme.markdown for further details. |
57 | 7 | * |
58 | 8 | * @author A. Grandt <php@grandt.com> |
59 | 9 | * @copyright 2014 A. Grandt |
60 | 10 | * @license GNU LGPL 2.1 |
61 | | - * @version 0.10 |
| 11 | + * @version 0.20 |
62 | 12 | */ |
63 | 13 | namespace com\grandt; |
64 | 14 |
|
65 | 15 | class BinString { |
66 | | - const VERSION = 0.10; |
| 16 | + const VERSION = 0.20; |
67 | 17 |
|
68 | 18 | private $has_mbstring = FALSE; |
69 | 19 | private $has_mb_shadow = FALSE; |
|
0 commit comments