Change default Sorting by Adding a Simple Collation to an 8-Bit Character Set - mysql

Posted previously the question with zero responses, so I am replacing it with further clarification and details from my research results based on this MySQL manual entry.
In the past, I've worked with alternate collations that allowed us to specify alternate default sorting. Mysql allows for this down to the column level, but I don't understand something to get it working.
Our customers use a standard set of one character codes in almost all references to any master table, and presenting these codes in the order they need is always very cumbersome and difficult using functions and routines in PHP.
SELECT * FROM myTable order by my_code
NORMAL, default sorting would return this: DESIRED, default sorting should return this:
my_code | Description my_code | Description
1 | Grade 1 P | Pre-Kindergarten
2 | Grade 2 K | Kindergarten
3 | Grade 3 1 | Grade 1
A | Adult 2 | Grade 2
K | Kindergarten 3 | Grade 3
P | Pre-Kindergarten A | Adult
The steps to accomplish this are described in the Docs at 10.4.3. , and examples are shown in the Docs at 10.1.78.
In the steps, it shows this table, and how the weights are specified. This, I think is where I get lost. I've altered the weights as shown below, putting "P" (x50P) and "K" (x4B) before "0" (x30), but all it accomplishes is changing the sorting so that "1" (x31) appears between "P" and "K", all other sorting appears to remain unchanged.
<collation name="latin1_test_ci">
<map>
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
50 4B 30 31 32 33 34 35 36 37 38 39 41 43 55 3A
3B 3C 3D 3E 3F 40 42 44 45 46 47 48 49 4A 4C 4D
4E 4F 51 52 53 54 56 57 58 59 5A 5B 5C 5D 5E 5F
60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
41 41 41 41 5C 5B 5C 43 45 45 45 45 49 49 49 49
44 4E 4F 4F 4F 4F 5D D7 D8 55 55 55 59 59 DE DF
41 41 41 41 5C 5B 5C 43 45 45 45 45 49 49 49 49
44 4E 4F 4F 4F 4F 5D F7 D8 55 55 55 59 59 DE FF
</map>
</collation>
Sort results WITH the Alternate Collation above
Hex |my_code | Description
32 | 2 |Grade 2
33 | 3 |Grade 3
41 | A |Adult Ed
4B | K |Kindergarten
31 | 1 |Grade 1
50 | P |Pre-K

I realize you said you wanted to change the collation, but this requires no ORDER BY and is worth considering. You can convert these to an ENUM type and they will sort in the order they appear in the ENUM.
CREATE TABLE myTable (
my_code ENUM('P', 'K', '1', '2', '3', 'A'),
...
)
Using numbers in ENUMs is strongly discouraged, so you'll have to be careful. The main issue is that numbers can be treated as an index or a value in the ENUM. So it's behavior depends on it's type, leading to unexpected results.

This table are weights table. If you want that P i less than K, then put 00 weight to P and 01 weight to K. To put a weight you should assign a value in 'letter position': for P position 50. Sample to put P as first order letter:
<collation name="latin1_test_ci">
<map>
FF FF FF FF FF FF FF 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
00 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F <-- first weight
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
41 41 41 41 5B 5D 5B 43 45 45 45 45 49 49 49 49
44 4E 4F 4F 4F 4F 5C D7 5C 55 55 55 59 59 DE DF
41 41 41 41 5B 5D 5B 43 45 45 45 45 49 49 49 49
44 4E 4F 4F 4F 4F 5C F7 5C 55 55 55 59 59 DE FF
</map>
</collation>
Edit: Adding test and compete table.
The complete table for should be:
<collation name="latin1_test_ci">
<map>
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 02 03 04 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 05 42 43 44 45 46 47 48 49 4A 01 4C 4D 4E 4F
00 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
41 41 41 41 5B 5D 5B 43 45 45 45 45 49 49 49 49
44 4E 4F 4F 4F 4F 5C D7 5C 55 55 55 59 59 DE DF
41 41 41 41 5B 5D 5B 43 45 45 45 45 49 49 49 49
44 4E 4F 4F 4F 4F 5C F7 5C 55 55 55 59 59 DE FF
</map>
</collation>
* Testing: *
mysql> create table b (a varchar(1) collate latin1_test_ci );
mysql> insert into b values
-> ( 'P' ),
-> ('K'),
-> ('A'),
-> ('1'),
-> ('2'),
-> ('3');
mysql> SHOW COLLATION LIKE 'latin1_test_ci';
+----------------+---------+----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+----------------+---------+----+---------+----------+---------+
| latin1_test_ci | latin1 | 56 | | | 0 |
+----------------+---------+----+---------+----------+---------+
1 row in set (0.00 sec)
mysql> select * from b order by a;
+------+
| a |
+------+
| P |
| K |
| 1 |
| 2 |
| 3 |
| A |
+------+
6 rows in set (0.00 sec)

I don't think you need a custom collation to accomplish your goals.
To order the result set:
ORDER BY FIELD(my_code, 'P','K','1','2','3','4','5','6',
'7','8','9','10','11','12','A')
To limit the result set:
WHERE my_code IN('K','1','2','3','4','5')
If you'll be writing this sort of functionality into a lot of queries, a helper function might be a good idea:
DELIMITER $$
CREATE FUNCTION `f_position`(in_char CHAR(1)) RETURNS INTEGER
BEGIN
RETURN FIELD(in_char, 'P','K','1','2','3','4','5','6',
'7','8','9','10','11','12','A');
END$$
DELIMITER ;
Just make sure that all possible codes are referenced in the function, and are placed in the order that you want.
With a helper function like that, you can write queries like so:
WHERE f_position(grade) BETWEEN f_position('K') AND f_position('5')
ORDER BY f_position(grade)
The only downside to using a helper function to limit result sets like that (as opposed to the WHERE grade IN(...)) is that the function call would prevent any indexes on the column "grade" from being used.

Related

Unknown compression method

Can someone explain me, what is that compression method used?
I tried to reverse engeneer old application. It using tcp connection and send messages using json.
All data was the plain json, but that data is json value "pb_rsp" was binary and i cant uncompress that.
120113837000265, Xanthus, EliteDog, flag30, 574949063200274 - thats a plain data. Around them some unknown separators.
I think thats encoded json, but cant detect method, help please
�
9181129d4be64c36ad42401c8227226f��
"Z
120113837000265Xanthus *8
84860c8bfafb48b1b6ef8b595fcf6246EEDEliteDog"flag30�(��0#H����0P�����0X�����0`j�
574949063200274Z
120113837000265Xanthus *8
84860c8bfafb48b1b6ef8b595fcf6246EEDEliteDog"flag30� �����0(�����02�(0#ZJ
107107ddR
or hex
1A D5 02 0A 0F 35 37 35 30 33 30 39 37 36 39 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 97 91 A4 EF D2 30 40 CF C5 C4 EF D2 30 48 01 50 9B E1 1C 5A 27 08 98 11 28 01 30 0E 40 50 4A 0C 0A 06 31 30 37 30 30 38 10 5A 18 5A 4A 0C 0A 06 31 30 37 30 30 39 10 0A 18 0A 52 00 5A 19 08 E0 12 28 02 30 0E 40 50 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 EB 12 28 05 30 0E 40 64 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 E1 12 28 04 30 0E 40 64 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 99 11 28 03 30 0E 40 64 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 60 AA F9 0F 1A C7 02 0A 0F 35 37 35 30 33 31 30 32 38 30 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 A1 A6 A4 EF D2 30 40 D9 DA C4 EF D2 30 48 01 50 9B E1 1C 5A 19 08 B4 10 28 01 30 0E 40 46 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 BF 10 28 02 30 0D 40 5F 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 B5 10 28 05 30 0E 40 5F 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 BE 10 28 04 30 0E 40 5F 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 C1 10 28 03 30 0E 40 5F 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 60 AA F9 0F 1A C7 02 0A 0F 35 37 35 30 33 31 31 35 34 37 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 E3 B6 A4 EF D2 30 40 9B EB C4 EF D2 30 48 01 50 9B E1 1C 5A 19 08 FD 11 28 03 30 0E 40 46 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 FC 11 28 01 30 0E 40 46 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 86 12 28 04 30 0D 40 5A 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 FE 11 28 05 30 0E 40 46 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 81 12 28 02 30 0E 40 46 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 60 AA F9 0F 1A D5 02 0A 0F 35 37 35 30 33 31 32 30 34 34 30 30 32 37 34 10 3F 1A 58 0A 0F 31 36 37 38 34 37 30 37 35 30 30 30 32 37 34 12 05 41 6B 61 72 64 20 09 2A 38 0A 20 38 34 38 36 30 63 38 62 66 61 66 62 34 38 62 31 62 36 65 66 38 62 35 39 35 66 63 66 36 32 34 36 12 03 45 45 44 1A 08 45 6C 69 74 65 44 6F 67 22 05 66 6C 61 67 33 30 EB A7 12 2A 39 0A 1C 77 6F 72 6C 64 52 6F 62 6F 74 2D 31 36 37 31 34 37 32 38 35 30 31 34 38 2D 33 33 39 12 0A 41 6E 6F 6E 79 6D 6F 75 73 31 1A 0D 70 69 63 5F 31 32 5F 5A 68 75 6A 75 65 38 86 C6 A4 EF D2 30 40 BE FA C4 EF D2 30 48 01 50 9B E1 1C 5A 27 08 A2 11 28 01 30 0E 40 3C 4A 0C 0A 06 31 30 37 30 30 38 10 63 18 63 4A 0C 0A 06 31 30 37 30 30 39 10 01 18 01 52 00 5A 19 08 E4 12 28 02 30 0E 40 41 4A 0C 0A 06 31 30 37 30 30 38 10 64 18 64 52 00 5A 19 08 E2 12 28 05 30 0E 40 46 4A 0C 0A 06 31 30 37 32 30 38 10 64 18 64 52 00 5A 19 08 E5 12 28 04 30 0E 40 46 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 5A 19 08 EC 12 28 03 30 0E 40 55 4A 0C 0A 06 31 30 37 31 30 38 10 64 18 64 52 00 60 AA F9 0F
or base64
Ev8HCiAwYjk5MGU1NzIwNzU0ZTNlODhlYTc2MDc3YmViNWNmYxji2AsicAoPMTQ1MTk2NDk1MDAwMjk0Eghzb29uMTAwNBoVcGljXzEwX0tlZXJtYW5fTElOU0hJKjgKIDg0ODYwYzhiZmFmYjQ4YjFiNmVmOGI1OTVmY2Y2MjQ2EgNFRUQaCEVsaXRlRG9nIgVmbGFnMzDrpxIohpEMMA9ABUjLneju0jBQm5GO79IwWIvtjO/SMGABapwCCg81NzQ5OTUyNTY5MDAyNzQScAoPMTQ1MTk2NDk1MDAwMjk0Eghzb29uMTAwNBoVcGljXzEwX0tlZXJtYW5fTElOU0hJKjgKIDg0ODYwYzhiZmFmYjQ4YjFiNmVmOGI1OTVmY2Y2MjQ2EgNFRUQaCEVsaXRlRG9nIgVmbGFnMzDrpxIgk+2M79IwKJuRju/SMDIbCOwSKAQwDEBfSgwKBjEwNzEwNxBkGGRSAggBMhsItRAoAzAMQF9KDAoGMTA3MTA3EGQYZFICCAEyGQi0ECgBMAlARkoMCgYxMDcwMDcQZBhkUgAyGQi4ECgCMA5AVUoMCgYxMDcyMDcQZBhkUgAyGQi2ECgFMA5AWkoMCgYxMDcyMDcQZBhkUgBqgAIKDzU3NDk5NjA5MTQwMDI3NBJYCg8xNjk1ODE1MjIwMDAyNjUSBUt3b24yIAwqOAogODQ4NjBjOGJmYWZiNDhiMWI2ZWY4YjU5NWZjZjYyNDYSA0VFRBoIRWxpdGVEb2ciBWZsYWczMOunEiCYi+ru0jAo0KLq7tIwMhkIuBAoAjAOQDJKDAoGMTA3MjA3EGQYZFIAMhkIgBIoATALQDxKDAoGMTA3MDA3EGQYZFIAMhkI/xEoBTAOQEZKDAoGMTA3MjA3EGQYZFIAMhkIthAoBDAOQEZKDAoGMTA3MjA3EGQYZFIAMhkIgRIoAzAOQEZKDAoGMTA3MTA3EGQYZFIAaoUCCg81NzUwMDUzNTMxMDAyNzQSWwoOMTk4NDcxMjQwMDAyNzESCUFtYW5kYTI2NSAGKjgKIDg0ODYwYzhiZmFmYjQ4YjFiNmVmOGI1OTVmY2Y2MjQ2EgNFRUQaCEVsaXRlRG9nIgVmbGFnMzDrpxIgo5367tIwKLPc/+7SMDIZCOQSKAEwDkBBSgwKBjEwNzAwNxBkGGRSADIZCOASKAIwCkBBSgwKBjEwNzAwNxBkGGRSADIZCJoRKAMwCUAFSgwKBjEwNzIwNxBkGGRSADIbCOESKAQwDUBkSgwKBjEwNzIwNxBkGGRSAggCMhkI6xIoBTAMQGRKDAoGMTA3MTA3EGQYZFIAggEGOTAwMDM3sAEBugEPNTc0OTk1MjU2OTAwMjc0
Thanks
Thats not a gzip or zip

Sending email to a gmail account via SMTP

I'm trying to make a SMTP client library and am trying to send email via the command line first.
250 SMTPUTF8
EHLO gmail.com
write to 0x7fb0e6c16130 [0x7fb0ea011a03] (37 bytes => 37 (0x25))
0000 - 17 03 03 00 20 3f a5 65-6f 8a a3 b8 a7 13 7e 70 .... ?.eo.....~p
0010 - 57 a1 7b ca c1 4b 25 56-39 b5 df d6 c4 b7 49 c1 W.{..K%V9.....I.
0020 - 32 f2 f4 5a c5 2..Z.
read from 0x7fb0e6c16130 [0x7fb0ea00d803] (5 bytes => 5 (0x5))
0000 - 17 03 03 00 c2 .....
read from 0x7fb0e6c16130 [0x7fb0ea00d808] (194 bytes => 194 (0xC2))
0000 - 23 b5 8f 8e 31 26 8a dd-98 ce fd 73 58 8b e4 f5 #...1&.....sX...
0010 - 0a d6 8d 7b a8 a0 97 fb-ef 48 84 9b 10 f4 58 2b ...{.....H....X+
0020 - 65 0c 61 29 17 f7 41 0b-c4 59 8a 87 87 4b f7 b9 e.a)..A..Y...K..
0030 - 7a 68 8c f8 1b ec 05 bb-fa 97 dc 81 76 ba 12 86 zh..........v...
0040 - ed a6 6f 06 44 74 e1 80-4c 24 37 a4 06 a6 40 9d ..o.Dt..L$7...#.
0050 - c9 57 b2 2d 6c a7 fe cf-bb 7b 32 4e 01 f2 65 94 .W.-l....{2N..e.
0060 - b5 1f f9 aa eb 73 c6 b8-6c 93 71 89 2c 84 83 ad .....s..l.q.,...
0070 - 73 bb 5a 8b 63 c4 5a 94-d9 65 fa 2e 3b 1a 3d 21 s.Z.c.Z..e..;.=!
0080 - f8 6f 97 f0 61 1d 13 b3-ee 68 cf ed 92 aa dd e0 .o..a....h......
0090 - 86 16 e3 14 71 ef b0 28-74 ec fa ba ad 9f e2 6d ....q..(t......m
00a0 - 05 c1 39 7a 65 71 21 34-e8 a7 be d1 6c 39 68 42 ..9zeq!4....l9hB
00b0 - 84 a2 8d 9e 7c 03 57 49-6f 5b c1 af 78 2d 72 e5 ....|.WIo[..x-r.
00c0 - 47 67 Gg
250-mx.google.com at your service, [2800:e2:37f:ecc6:9426:2eed:fdd4:795b]
250-SIZE 157286400
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
MAIL FROM:kyle#live.com
write to 0x7fb0e6c16130 [0x7fb0ea011a03] (46 bytes => 46 (0x2E))
0000 - 17 03 03 00 29 1a 31 f6-c0 39 da 57 95 3e 85 0c ....).1..9.W.>..
0010 - 48 86 29 1c a5 c2 80 cb-40 79 ef fa 66 dd e7 10 H.).....#y..f...
0020 - 8e dd 14 d2 f3 c8 07 98-ff 06 68 8b 4d b2 ..........h.M.
read from 0x7fb0e6c16130 [0x7fb0ea00d803] (5 bytes => 5 (0x5))
0000 - 17 03 03 00 44 ....D
read from 0x7fb0e6c16130 [0x7fb0ea00d808] (68 bytes => 68 (0x44))
0000 - 4a 7d f0 e2 01 00 00 eb-8b c0 82 70 fd 09 1a 50 J}.........p...P
0010 - 3b b3 fb ab 8a a1 83 df-af cd c8 bb 96 4f eb 19 ;............O..
0020 - 38 19 fa 4c 28 5d 75 f9-a4 d5 20 38 c4 f3 b6 db 8..L(]u... 8....
0030 - cd 44 3f 36 6a 8c f6 79-38 2e d3 2f b2 c4 4d 91 .D?6j..y8../..M.
0040 - 51 e8 2f ff Q./.
555 5.5.2 Syntax error. d7si1665405vsj.297 - gsmtp
The problem is no matter what email address I use I get a syntax error. What am I doing wrong?
Missing brackets enclosing your source mailbox.
The first step in the procedure is the MAIL command.
MAIL FROM:<reverse-path> [SP <mail-parameters> ] <CRLF>
The portion of the first or only argument contains
the source mailbox (between "<" and ">" brackets), which can be
used to report errors (see Section 4.2 for a discussion of error
reporting). If accepted, the SMTP server returns a "250 OK" reply.
-- from RFC 5321 Section 3.3 (emphasis mine)
Change this
MAIL FROM:kyle#live.com
Into this:
MAIL FROM:<kyle#live.com>
That being said..
I'm trying to make a SMTP client library
Please don't do that! Almost every programming language has such libraries already, most often even in the respective stdlib. And the authors of those have generally carefully considered more edge cases than you and I ever could. Do not reinvent the wheel, especially if handling mail (where it is all too easy to cause interoperability issues or new vectors for spam/abuse).

When getting a hexadecimal dump in VS, what do those periods mean?

For example:
%PDF-1.3..%.....
...1 0 obj..<<..
from
25 50 44 46 2D 31 2E 33 0D 0A 25 E2 E3 CF D3 0D
0A 0D 0A 31 20 30 20 6F 62 6A 0D 0A 3C 3C 0D 0A
Do they represent numbers that don't fit in ASCII?

How to convert BLOB object to PL Json

i am using below code to load image file from server to BLOB Object
but after convert it to clob and put it into json it reformatted.
how can i fix this
FUNCTION get_person_image(v_file_name varchar2) RETURN json AS
tmp_blob blob default EMPTY_BLOB();
tmp_bfile bfile := null;
dest_offset integer := 1;
src_offset integer := 1;
v_ret_json json := json();
BEGIN
tmp_bfile := BFILENAME('PICTURES', v_file_name);
DBMS_LOB.OPEN(tmp_bfile, DBMS_LOB.FILE_READONLY);
DBMS_LOB.CREATETEMPORARY(tmp_blob, TRUE);
DBMS_LOB.LOADBLOBFROMFILE(tmp_blob,
tmp_bfile,
DBMS_LOB.LOBMAXSIZE,
dest_offset,
src_offset);
DBMS_LOB.CLOSE(tmp_bfile);
v_ret_json.put('name', v_file_name);
v_ret_json.put('image', blob_to_clob(tmp_blob));
RETURN v_ret_json;
END get_person_image;
FUNCTION blob_to_clob(blob_in IN BLOB) RETURN CLOB AS
v_clob CLOB;
v_varchar VARCHAR2(32767);
v_start PLS_INTEGER := 1;
v_buffer PLS_INTEGER := 32767;
begin
DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
FOR i IN 1 .. CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer) LOOP
v_varchar := UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(blob_in,
v_buffer,
v_start));
DBMS_LOB.WRITEAPPEND(v_clob, LENGTH(v_varchar), v_varchar);
v_start := v_start + v_buffer;
END LOOP;
RETURN v_clob;
END blob_to_clob;
Once the get_person_image read image file the CLOB Contains data like below HEX:
00 01 00 00 FF DB 00 84 00 09 06 07 13 13 12 15
13 12 13 15 16 15 15 18 1D 17 17 16 18 17 17 16
18 18 17 18 1A 18 18 17 18 17 18 18 1D 28 20 1A
1A 25 1B 18 17 22 31 21 25 29 2B 2E 2E 2E 17 20
33 38 33 2C 37 28 2D 2E 2B 01 0A 0A 0A 0E 0D 0E
1B 10 10 1B 2D 25 20 25 2D 2D 2D 2D 2D 2D 2D 2D
2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2F 2D 2D 2D 2D 2D
2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
2D 2D 2D 2D 2D 2D 2D 2D 2D 2D FF C0 00 11 08 01
0F 00 BA 03 01 22 00 02 11 01 03 11 01 FF C4 00
1C 00 00 01 05 01 01 01 00 00 00 00 00 00 00 00
00 00 05 00 03 04 06 07 02 01 08 FF C4 00 43 10
00 01 02 03 05 05 06 03 07 02 05 02 07 00 00 00
01 02 11 00 03 21 04 05 12 31 41 06 51 61 71 91
22 32 81 A1 B1 F0 13 C1 D1 14 23 42 52 62 82 E1
07 72 15 92 A2 B2 F1 33 C2 16 24 43 63 74 B3 F3
FF C4 00 18 01 00 03 01 01 00 00 00 00 00 00 00
00 00 00 00 00 00 01 02 03 04 FF C4 00 21 11 01
01 00 03 01 01 01 01 01 00 03 01 00 00 00 00 00
01 02 11 21 31 41 03 12 22 42 51 81 32 FF DA 00
0C 03 01 00 02 11 03 11 00 3F 00 DB A3 89 B3 00
04 9A 01 1E A9 4D 19 8E DF 6D 62 D4 A3 67 B3 BD
28 A5 0D FB 9F D7 FE 61 5B A3 93 69 3B 5F B7 69
41 32 E4 76 D4 EC 5B 2E 35 1E 9C 6B BA 33 F9 B6
D5 AD 41 53 89 5A F4 4E 89 F9 0F 7C E2 39 93 84
BB E2 51 A5 32 F3 88 76 89 85 CA 52 5B F3 1E 3A
87 FA C4 5B B6 D2 69 2E D7 7B 2A A1 FA 51 23 A6
71 09 53 54 4E A4 EF 67 3E 03 21 E3 0A 4A 10 1A
98 BA 81 EB E6 63 A5 CF 03 26 E6 3D E5 EF 93 93
45 6E CC AA C4 09 FB C5 37 E9 15 5F 5C 93 E0 22
44 A4 24 1F BB 96 90 77 9E D2 FC E2 32 2D 6F 90
61 F9 8D 49 E5 BA 1C 33 30 A5 CD 3A 97 30 C9 39
04 20 E2 99 32 BB 80 0F D6 24 D9 2F 79 45 60 09
20 F1 38 49 26 9A AA 83 C6 2B 33 A6 13 5C 87 31
EB 1D D8 E8 71 00 4B 74 FE 7C 61 06 AB 79 4A 49
97 2F EE A5 8C 75 0A 49 ED 00 CC A0 A3 91 0C 68
74 2D 1D DD 56 F9 72 08 29 99 50 18 B1 A1 6A 54
0A 13 C7 D2 33 4B 55 F4 65 E6 5D 67 47 A2 79 EF
3E F9 C0 5D ED 31 59 13 E8 3A 6B 07 A3 91 F4 75
DB 7B 95 80 42 82 81 19 1A 1C B4 3A C1 8B 35 A9
2B 1D 93 96 63 50 63 06 D9 CB DE 6C 89 92 E6 29
01 68 52 80 51 72 0A 08 EC F6 AA 03 38 53 BB D2
B5 70 0D D6 6D F2 A9 33 5E 59 55 49 39 12 4A 58
66 06 7A D2 1E F4 5F CE DA 58 8F 60 3D C5 7F 4A
B4 20 29 2A 0F AB 1D 60 BB C5 22 CD 3D 85 0A 14
04 50 A1 42 80 14 28 50 A0 05 0A 14 28 02 AF B6
D7 DF D9 E4 16 3D B5 F6 53 F3 57 24 FA B4 63 CA
99 53 9B E6 B5 1F 24 8E 3E F9 17 DB 5B EC CF
.....
and when i open as text in PLSQL it is something like this :
���JFIF
after v_ret_json.put('image', blob_to_clob(tmp_blob)); it reformatted as :
Hex View :
7B 0D 0A 20 20 22 6E 61 6D 65 22 20 3A 20 22 34
31 32 2E 70 6E 67 22 2C 0D 0A 20 20 22 69 6D 61
67 65 22 20 3A 20 22 5C 75 46 46 46 44 5C 75 46
46 46 44 5C 75 46 46 46 44 4A 46 49 46 5C 75 30
30 30 30 5C 75 30 30 30 31 5C 75 30 30 30 31 5C
75 30 30 30 30 5C 75 30 30 30 30 5C 75 30 30 30
31 5C 75 30 30 30 30 5C 75 30 30 30 31 5C 75 30
30 30 30 5C 75 30 30 30 30 5C 75 46 46 46 44 5C
75 46 46 46 44 5C 75 46 46 46 44 5C 75 30 30 30
30 5C 74 5C 75 30 30 30 36 5C 75 30 30 30 37 5C
75 30 30 31 33 5C 75 30 30 31 33 5C 75 30 30 31
32 5C 75 30 30 31 35 5C 75 30 30 31 33 5C 75 30
30 31 32 5C 75 30 30 31 33 5C 75 30 30 31 35 5C
75 30 30 31 36 5C 75 30 30 31 35 5C 75 30 30 31
35 5C 75 30 30 31 38 5C 75 30 30 31 44 5C 75 30
30 31 37 5C 75 30 30 31 37 5C 75 30 30 31 36 5C
75 30 30 31 38 5C 75 30 30 31 37 5C 75 30 30 31
37 5C 75 30 30 31 36 5C 75 30 30 31 38 5C 75 30
30 31 38 5C 75 30 30 31 37 5C 75 30 30 31 38 5C
75 30 30 31 41 5C 75 30 30 31 38 5C 75 30 30 31
38 5C 75 30 30 31 37 5C 75 30 30 31 38 5C 75 30
30 31 37 5C 75 30 30 31 38 5C 75 30 30 31 38 5C
75 30 30 31 44 28 20 5C 75 30 30 31 41 5C 75 30
30 31 41 25 5C 75 30 30 31 42 5C 75 30 30 31 38
5C 75 30 30 31 37 5C 22 31 21 25 29 2B 2E 2E 2E
5C 75 30 30 31 37 20 33 38 33 2C 37 28 2D 2E 2B
5C 75 30 30 30 31 5C 6E 5C 6E 5C 6E 5C 75 30 30
30 45 5C 72 5C 75 30 30 30 45 5C 75 30 30 31 42
5C 75 30 30 31 30 5C 75 30 30 31 30 5C 75 30 30
31 42 2D 25 20 25 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
2D 2D 2D 2D 2D 2D 2D 2D 2F 2D 2D 2D 2D 2D 2D 2D
2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
2D 2D 2D 2D 2D 2D 2D 2D 5C 75 46 46 46 44 5C 75
46 46 46 44 5C 75 30 30 30 30 5C 75 30 30 31 31
5C 62 5C 75 30 30 30 31 5C 75 30 30 30 46 5C 75
30 30 30 30 5C 75 46 46 46 44 5C 75 30 30 30 33
5C 75 30 30 30 31 5C 22 5C 75 30 30 30 30 5C 75
30 30 30 32 5C 75 30 30 31 31 5C 75 30 30 30 31
5C 75 30 30 30 33 5C 75 30 30 31 31 5C 75 30 30
30 31 5C 75 46 46 46 44 5C 75 46 46 46 44 5C 75
30 30 31 43 5C 75 30 30 30 30 5C 75 30 30 30 30
5C 75 30 30 30 31 5C 75 30 30 30 35 5C 75 30 30
30 31 5C 75 30 30 30 31 5C 75 30 30 30 31 5C 75
30 30 30 30 5C 75 30 30 30 30 5C 75 30 30 30 30
5C 75 30 30 30 30 5C 75 30 30 30 30 5C 75 30 30
30 30 5C 75 30 30 30 30 5C 75 30 30 30 30 5C 75
30 30 30 30 5C 75 30 30 30 30 5C 75 30 30 30 35
5C 75 30 30 30 30 5C 75 30 30 30 33 5C 75 30 30
Text View :
"name" : "412.png",
"image" : "\uFFFD\uFFFD\uFFFDJFIF\u0000\u0001\u0001\u0000\u0000\u0001\u0000\u0001\u0000\u0000\uFFFD\uFFFD\uFFFD\u0000\t\u0006\u0007\u0013\u0013\u0012\u0015\u0013\u0012\u0013\u0015\u0016\u0015\u0015\u0018\u001D\u0017\u0017\u0016\u0018\u0017\u0017\u0016\u0018\u0018\u0017\u0018\u001A\u0018\u0018\u0017\u0018\u0017\u0018\u0018\u001D( \u001A\u001A%\u001B\u0018\u0017\"1!%)+...\u0017 383,7(-.+\u0001\n\n\n\u000E\r\u000E\u001B\u0010\u0010\u001B-% %------------------/-------------------------------\uFFFD\uFFFD\u0000\u0011\b\u0001\u000F\u0000\uFFFD\u0003\u0001\"\u0000\u0002\u0011\u0001\u0003\u0011\u0001\uFFFD\uFFFD\u001C\u0000\u0000\u0001\u0005\u0001\u0001\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0005\u0000\u0003\u0004\u0006\u0007\u0002\u0001\b\uFFFD\uFFFDC\u0010\u0000\u0001\u0002\u0003\u0005\u0005\u0006\u0003\u0007\u0002\u0005\u0002\u0007\u0000\u0000\u0000\u0001\u0002\u0011\u0000\u0003!\u0004\u0005\u00121A\u0006Qaq\uFFFD\"2\uFFFD\uFFFD\uFFFD\uFFFD\u0014#BRb\uFFFD\uFFFD\u0015\uFFFD\uFFFD\uFFFD\uFFFD$Cct\uFFFD\uFFFD\u0018\u0001\u0000\u0003\u0001\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0003\u0004\uFFFD\uFFFD!\u0011\u0001\u0001\u0000\u0003\u0001\u0001\u0001\u0001\u0001\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0011!1A\u0003\u0012\"BQ\uFFFD2\uFFFD\uFFFD\f\u0003\u0001\u0000\u0002\u0011\u0003\u0011\u0000?\u0000\u06E3\uFFFD\uFFFD\u0000\u0004\uFFFD\u0001\u001E\uFFFDM\u0019\uFFFD\uFFFDb\u0523g\uFFFD\uFFFD(\uFFFD\r\uFFFD\uFFFD\uFFFDa[\uFFFD\uFFFDi;_\uFFFDiA2\uFFFD\uFFFD5\u001E\uFFFDk\uFFFD3\uFFFD\uFFFD\u056DAS\uFFFDZ\uFFFD\u000F|\uFFFD\uFFFD\uFFFD\uFFFD2\uFFFD\uFFFD\uFFFD[\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD.\uFFFD*\uFFFD\uFFFDQ#\uFFFDq\tSTN\uFFFD\uFFFD\u0003!\uFFFD\u0010\u001A\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD&\uFFFD\uF4D3En\u032A

How to filter regex in SQL developer

I have receive some kind of below regrex message with random set as below pattern. I want to filter this message by insert filter table in SQL developer how to make the pattern to filter out. Query to insert the filter is below.
37 35 32 41 44 44 37 36 32 46 34 34 34 45 45 34 42 31 31 34 31 41 36 43 39
44 37 41 35 45 35 39 20 44 61 74 65 54 69 6D 65 20 3A 20 53 75 6E 20 41 75 67 20 32 30
20 32 30 3A 30 37 3A 33 39 20 41 53 54 20 32 30 31 37 2C 20 65 72 72 6F 72 4D 65 73 73
61 67 65 20 3A 20 45 78 63 65 70 74 69 6F 6E 20 67 65 6E 65 72 61 74 65 64 20 6F 6E 20
D9 A2 D9 A0 D9 A1 D9 A7 2D D9 A0 D9 A8 2D D9 A2 D9 A0 20 D9 A2 D9 A0 3A D9 A0 D9 A7 3A D9
A5 D9 A0 0A 0A 45 78 63 65 70 74 69 6F 6E 3A 20 6A 61 76 61 2E 6C
insert
into FILTER_IGNR (
ID_ALARM_FILTER_IGNR,
FILTER_PATTERN,
CREATED_DATE_TIME,
UPDATED_DATE_TIME,
IS_ACTIVE)
select MAX(ID_ALARM_FILTER_IGNR)+1,
'.*ERROR.*', -- Check and change in this one
sysdate,
sysdate,
1
from FILTER_IGNR