Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $singleByteCharacters = str_split('abcdefghijklmnopqrstuvwxyz ');
- $multiByteCharacters = array('…', 'ü', 'ö', 'ä');
- $imePrefs = array(
- 'scheme' => 'Q',
- 'input-charset' => 'utf-8',
- 'output-charset' => 'utf-8',
- 'line-length' => 74,
- 'line-break-chars' => "\r\n",
- );
- $errorPositions = array();
- for ($strlen = 1; $strlen < 200; $strlen++) {
- for ($i = 0; $i < 1000; $i++) {
- $subject = '';
- $multiBytePosition = rand(1, $strlen);
- for ($j = 0; $j < $strlen; $j++) {
- if ($j == $multiBytePosition) {
- $array = &$multiByteCharacters;
- } else {
- $array = &$singleByteCharacters;
- }
- $index = array_rand($array);
- $subject .= $array[$index];
- }
- $subject = substr($subject, 1);
- if (!@iconv_mime_encode('subject', $subject, $imePrefs)) {
- if (!isset($errorPositions[$multiBytePosition])) {
- $errorPositions[$multiBytePosition] = 0;
- }
- $errorPositions[$multiBytePosition]++;
- }
- }
- }
- ksort($errorPositions);
- foreach ($errorPositions as $position => $errorCount) {
- echo "$position: $errorCount\n";
- }
- # example output:
- # 23: 161
- # 24: 238
- # 25: 846
- # 49: 1
- # 50: 19
- # 51: 47
- # 52: 144
- # 53: 264
- # 54: 299
- # 55: 119
- # 78: 3
- # 79: 5
- # 80: 26
- # 81: 44
- # 82: 58
- # 83: 111
- # 84: 141
- # 85: 149
- # 86: 50
- # 107: 1
- # 108: 2
- # 109: 4
- # 110: 17
- # 111: 22
- # 112: 46
- # 113: 60
- # 114: 72
- # 115: 72
- # 116: 62
- # 117: 32
- # 138: 3
- # 139: 1
- # 140: 8
- # 141: 15
- # 142: 23
- # 143: 31
- # 144: 30
- # 145: 23
- # 146: 27
- # 147: 21
- # 148: 8
- # 166: 1
- # 168: 2
- # 169: 1
- # 170: 3
- # 171: 5
- # 172: 16
- # 173: 10
- # 174: 16
- # 175: 9
- # 176: 5
- # 177: 15
- # 178: 5
- # 179: 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement