How to convert BLOB object to PL Json - 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
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
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?
Convert captured packet data to html in C
I have captured a packet using libpcap and have the packet data in a char array. When I print it in hex and ascii the output is 47 45 54 20 2f 62 72 6f 77 73 65 2f 64 69 63 74 GET /browse/dict 69 6f 6e 61 72 79 3f 73 3d 74 20 48 54 54 50 2f ionary?s=t HTTP/ 31 2e 31 0d 0a 48 6f 73 74 3a 20 77 77 77 2e 64 1.1..Host: www.d 69 63 74 69 6f 6e 61 72 79 2e 63 6f 6d 0d 0a 55 ictionary.com..U 73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c ser-Agent: Mozil ..... ...... 41 31 25 32 43 31 30 31 25 33 41 31 25 32 43 32 A1%2C101%3A1%2C2 25 33 41 31 25 32 43 31 30 32 25 33 41 31 25 32 %3A1%2C102%3A1%2 43 31 30 33 25 33 41 31 25 32 43 33 25 33 41 31 C103%3A1%2C3%3A1 ............ ..... Now I want to convert above http request/response from captured packet to html tags. How can I do that?
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
Change default Sorting by Adding a Simple Collation to an 8-Bit Character Set
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.