Skip to content

Commit fc619d3

Browse files
committed
Stepping to version 0.2.0
1 parent 33ba6a8 commit fc619d3

File tree

3 files changed

+9
-109
lines changed

3 files changed

+9
-109
lines changed

BinString.php

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,19 @@
11
<?php
22
/**
33
* 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.
45
*
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.
577
*
588
* @author A. Grandt <php@grandt.com>
599
* @copyright 2014 A. Grandt
6010
* @license GNU LGPL 2.1
61-
* @version 0.10
11+
* @version 0.20
6212
*/
6313
namespace com\grandt;
6414

6515
class BinString {
66-
const VERSION = 0.10;
16+
const VERSION = 0.20;
6717

6818
private $has_mbstring = FALSE;
6919
private $has_mb_shadow = FALSE;

BinStringStatic.php

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,19 @@
11
<?php
22
/**
33
* If you use mbstring.func_overload, or the server you are running on has it enabled, you are in trouble.
4-
*
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.
4+
* This class will help overcome that, by provide alternative functions to work around it.
365
*
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.
577
*
588
* @author A. Grandt <php@grandt.com>
599
* @copyright 2014 A. Grandt
6010
* @license GNU LGPL 2.1
61-
* @version 0.10
11+
* @version 0.20
6212
*/
6313
namespace com\grandt;
6414

6515
class BinStringStatic {
66-
const VERSION = 0.10;
16+
const VERSION = 0.20;
6717

6818
/**
6919
* mbstring.func_overload has an undocumented feature, to retain access to the original function.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "grandt/binstring",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"type": "library",
55
"description": "A class for working around the use of mbstring.func_override",
66
"keywords": ["mbstring", "binary strings"],

0 commit comments

Comments
 (0)