Skip to content

Commit

Permalink
Fix indexes in ascii char groups
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoiq committed Apr 2, 2022
1 parent 4dc5d82 commit 8e6f1d2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 51 deletions.
39 changes: 22 additions & 17 deletions src/common/consts/AsciiChars.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,46 @@ class AsciiChars
{
use StaticClassMixin;

public const SPECIAL_WITHOUT_WHITESPACE = [
public const SPECIAL_CHARS = [
Char::NUL, Char::SOH, Char::STX, Char::ETX, Char::EOT, Char::ENQ, Char::ACK, Char::BEL,
Char::BS,/*Char::HT, Char::LF,*/Char::VT, Char::FF,/*Char::CR,*/Char::SO, Char::SI,
Char::BS, Char::HT, Char::LF, Char::VT, Char::FF, Char::CR, Char::SO, Char::SI,
Char::DLE, Char::DC1, Char::DC2, Char::DC3, Char::DC4, Char::NAK, Char::SYN, Char::ETB,
Char::CAN, Char::EM, Char::SUB, Char::ESC, Char::FS, Char::GS, Char::RS, Char::US,
Char::DEL,
127 => Char::DEL,
];
public const SPECIAL_CHARS = [

public const SPECIAL_WITHOUT_WHITESPACE = [
Char::NUL, Char::SOH, Char::STX, Char::ETX, Char::EOT, Char::ENQ, Char::ACK, Char::BEL,
Char::BS, Char::HT, Char::LF, Char::VT, Char::FF, Char::CR, Char::SO, Char::SI,
Char::BS, /* HT & LF */ 11 => Char::VT, Char::FF,/*CR*/ 14 => Char::SO, Char::SI,
Char::DLE, Char::DC1, Char::DC2, Char::DC3, Char::DC4, Char::NAK, Char::SYN, Char::ETB,
Char::CAN, Char::EM, Char::SUB, Char::ESC, Char::FS, Char::GS, Char::RS, Char::US,
Char::DEL,
127 => Char::DEL,
];

public const WHITESPACE = [' ', "\t", "\r", "\n"];
public const WHITESPACE = [9 => "\t", 10 => "\n", 13 => "\r", 32 => ' '];

public const UPPER_LETTERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
public const LOWER_LETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
public const UPPER_LETTERS = [65 => 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
public const LOWER_LETTERS = [97 => 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
public const LETTERS = self::UPPER_LETTERS + self::LOWER_LETTERS;

public const NUMBERS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
public const NUMBERS = [48 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
public const ALPHANUMERIC = self::LETTERS + self::NUMBERS;

public const OPERATORS = ['+', '-', '*', '/', '<', '>', '=', '~', '^'];
public const PUNCTUATION = [',', '.', ':', ';', '!', '?'];
public const BRACKETS = ['(', ')', '[', ']', '{', '}'];
public const QUOTES = ['"', "'", '`'];
public const OTHER = ['#', '$', '%', '&', '@', '_', '|', '\\'];
public const OPERATORS = [42 => '*', 43 => '+', 45 => '-', 47 => '/', 60 => '<', 61 => '=', 62 => '>', 94 => '^', 126 => '~'];
public const PUNCTUATION = [33 => '!', 44 => ',', 46 => '.', 58 => ':', 59 => ';', 63 => '?'];
public const BRACKETS = [40 => '(', 41 => ')', 91 => '[', 93 => ']', 123 => '{', 125 => '}'];
public const QUOTES = [34 => '"', 39 => "'", 96 => '`'];
public const OTHER = [35 => '#', 36 => '$', 37 => '%', 38 => '&', 64 => '@', 92 => '\\', 95 => '_', 124 => '|'];
public const SYMBOLS = self::OPERATORS + self::PUNCTUATION + self::BRACKETS + self::QUOTES + self::OTHER;

public const PRINTABLE = self::ALPHANUMERIC + self::SYMBOLS + self::WHITESPACE;
public const ALL = self::ALPHANUMERIC + self::SYMBOLS + self::WHITESPACE + self::SPECIAL_WITHOUT_WHITESPACE;

public const BASE_64 = self::ALPHANUMERIC + ['+', '/'];
public const BASE_64_URL = self::ALPHANUMERIC + ['-', '_']; // RFC 4648
// RFC 4648
public const BASE_64 = self::NUMBERS + self::LETTERS + [43 => '+', 47 => '/'];
public const BASE_64_URL = self::NUMBERS + self::LETTERS + [45 => '-', 95 => '_'];
public const BASE_32 = self::UPPER_LETTERS + [50 => 2, 3, 4, 5, 6, 7];
public const BASE_32_HEX = self::NUMBERS + [65 => 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V'];
public const BASE_16 = self::NUMBERS + [65 => 'A', 'B', 'C', 'D', 'E', 'F'];

}
68 changes: 34 additions & 34 deletions src/common/consts/Char.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@
/**
* Special characters ASCII codes
*
* Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char
* -------------- -------------- -------------- --------------
* 0 00h NUL (null) 32 20h " " 64 40h @ 96 60h `
* 1 01h SOH (start of heading) 33 21h ! 65 41h A 97 61h a
* 2 02h STX (start of text) 34 22h " 66 42h B 98 62h b
* 3 03h ETX (end of text) 35 23h # 67 43h C 99 63h c
* 4 04h EOT (end of transmission) 36 24h $ 68 44h D 100 64h d
* 5 05h ENQ (enquiry) 37 25h % 69 45h E 101 65h e
* 6 06h ACK (acknowledge) 38 26h & 70 46h F 102 66h f
* 7 07h BEL (bell) 39 27h ' 71 47h G 103 67h g
* 8 08h BS (backspace) 40 28h ( 72 48h H 104 68h h
* 9 09h TAB (horizontal tab) 41 29h ) 73 49h I 105 69h i
* 10 0Ah LF (NL line feed, new line) 42 2Ah * 74 4Ah J 106 6Ah j
* 11 0Bh VT (vertical tab) 43 2Bh + 75 4Bh K 107 6Bh k
* 12 0Ch FF (NP form feed, new page) 44 2Ch , 76 4Ch L 108 6Ch l
* 13 0Dh CR (carriage return) 45 2Dh - 77 4Dh M 109 6Dh m
* 14 0Eh SO (shift out) 46 2Eh . 78 4Eh N 110 6Eh n
* 15 0Fh SI (shift in) 47 2Fh / 79 4Fh O 111 6Fh o
* 16 10h DLE (data link escape) 48 30h 0 80 50h P 112 70h p
* 17 11h DC1 (device control 1) 49 31h 1 81 51h Q 113 71h q
* 18 12h DC2 (device control 2) 50 32h 2 82 52h R 114 72h r
* 19 13h DC3 (device control 3) 51 33h 3 83 53h S 115 73h s
* 20 14h DC4 (device control 4) 52 34h 4 84 54h T 116 74h t
* 21 15h NAK (negative acknowledge) 53 35h 5 85 55h U 117 75h u
* 22 16h SYN (synchronous idle) 54 36h 6 86 56h V 118 76h v
* 23 17h ETB (end of trans. block) 55 37h 7 87 57h W 119 77h w
* 24 18h CAN (cancel) 56 38h 8 88 58h X 120 78h x
* 25 19h EM (end of medium) 57 39h 9 89 59h Y 121 79h y
* 26 1Ah SUB (substitute) 58 3Ah : 90 5Ah Z 122 7Ah z
* 27 1Bh ESC (escape) 59 3Bh ; 91 5Bh [ 123 7Bh {
* 28 1Ch FS (file separator) 60 3Ch < 92 5Ch \ 124 7Ch |
* 29 1Dh GS (group separator) 61 3Dh = 93 5Dh ] 125 7Dh }
* 30 1Eh RS (record separator) 62 3Eh > 94 5Eh ^ 126 7Eh ~
* 31 1Fh US (unit separator) 63 3Fh ? 95 5Fh _ 127 7Fh DEL
* Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char
* ------------------------------------- ------------ ------------ -------------
* 0 00h NUL (null) 32 20h " " 64 40h @ 96 60h `
* 1 01h SOH (start of heading) 33 21h ! 65 41h A 97 61h a
* 2 02h STX (start of text) 34 22h " 66 42h B 98 62h b
* 3 03h ETX (end of text) 35 23h # 67 43h C 99 63h c
* 4 04h EOT (end of transmission) 36 24h $ 68 44h D 100 64h d
* 5 05h ENQ (enquiry) 37 25h % 69 45h E 101 65h e
* 6 06h ACK (acknowledge) 38 26h & 70 46h F 102 66h f
* 7 07h BEL (bell) 39 27h ' 71 47h G 103 67h g
* 8 08h BS (backspace) 40 28h ( 72 48h H 104 68h h
* 9 09h TAB (horizontal tab) 41 29h ) 73 49h I 105 69h i
* 10 0Ah LF (NL line feed, new line) 42 2Ah * 74 4Ah J 106 6Ah j
* 11 0Bh VT (vertical tab) 43 2Bh + 75 4Bh K 107 6Bh k
* 12 0Ch FF (NP form feed, new page) 44 2Ch , 76 4Ch L 108 6Ch l
* 13 0Dh CR (carriage return) 45 2Dh - 77 4Dh M 109 6Dh m
* 14 0Eh SO (shift out) 46 2Eh . 78 4Eh N 110 6Eh n
* 15 0Fh SI (shift in) 47 2Fh / 79 4Fh O 111 6Fh o
* 16 10h DLE (data link escape) 48 30h 0 80 50h P 112 70h p
* 17 11h DC1 (device control 1) 49 31h 1 81 51h Q 113 71h q
* 18 12h DC2 (device control 2) 50 32h 2 82 52h R 114 72h r
* 19 13h DC3 (device control 3) 51 33h 3 83 53h S 115 73h s
* 20 14h DC4 (device control 4) 52 34h 4 84 54h T 116 74h t
* 21 15h NAK (negative acknowledge) 53 35h 5 85 55h U 117 75h u
* 22 16h SYN (synchronous idle) 54 36h 6 86 56h V 118 76h v
* 23 17h ETB (end of trans. block) 55 37h 7 87 57h W 119 77h w
* 24 18h CAN (cancel) 56 38h 8 88 58h X 120 78h x
* 25 19h EM (end of medium) 57 39h 9 89 59h Y 121 79h y
* 26 1Ah SUB (substitute) 58 3Ah : 90 5Ah Z 122 7Ah z
* 27 1Bh ESC (escape) 59 3Bh ; 91 5Bh [ 123 7Bh {
* 28 1Ch FS (file separator) 60 3Ch < 92 5Ch \ 124 7Ch |
* 29 1Dh GS (group separator) 61 3Dh = 93 5Dh ] 125 7Dh }
* 30 1Eh RS (record separator) 62 3Eh > 94 5Eh ^ 126 7Eh ~
* 31 1Fh US (unit separator) 63 3Fh ? 95 5Fh _ 127 7Fh DEL
*/
class Char
{
Expand Down

0 comments on commit 8e6f1d2

Please sign in to comment.