Overview
Comment: | s_expressions-encodings: add base-64 conversions with custom representations of 62 and 63 |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a41d6ed1739850ed074f3ded3c21aa6d |
User & Date: | nat on 2014-04-13 17:17:03 |
Other Links: | manifest | tags |
Context
2014-04-14
| ||
21:29 | s_expressions-encodings: add a test for the user-defined base-64 charset check-in: 6236ad7b60 user: nat tags: trunk | |
2014-04-13
| ||
17:17 | s_expressions-encodings: add base-64 conversions with custom representations of 62 and 63 check-in: a41d6ed173 user: nat tags: trunk | |
2014-04-12
| ||
16:19 | natools-references: add support of references to constant check-in: 8c650fd927 user: nat tags: trunk | |
Changes
Modified src/natools-s_expressions-encodings.adb from [55ec865df9] to [6be873c8b5].
︙ | ︙ | |||
327 328 329 330 331 332 333 334 335 336 337 338 | Encode_Base64 (Result (Cursor .. Cursor + 3), Data (I)); I := I + 1; end if; Cursor := Cursor + 4; end loop; return Result; end Encode_Base64; end Natools.S_Expressions.Encodings; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | Encode_Base64 (Result (Cursor .. Cursor + 3), Data (I)); I := I + 1; end if; Cursor := Cursor + 4; end loop; return Result; end Encode_Base64; --------------------------------- -- Base-64 with other charsets -- --------------------------------- function Decode_Base64 (Data : in Atom; Digit_62, Digit_63 : in Octet) return Atom is Recoded : Atom := Data; begin for I in Recoded'Range loop if Recoded (I) = Digit_62 then Recoded (I) := Plus; elsif Recoded (I) = Digit_63 then Recoded (I) := Slash; end if; end loop; return Decode_Base64 (Recoded); end Decode_Base64; function Encode_Base64 (Data : in Atom; Digit_62, Digit_63 : in Octet) return Atom is Result : Atom := Encode_Base64 (Data); Last : Count := Result'Last; begin for I in Result'Range loop if Result (I) = Plus then Result (I) := Digit_62; elsif Result (I) = Slash then Result (I) := Digit_63; elsif Result (I) = Base64_Filler then for J in I + 1 .. Result'Last loop pragma Assert (Result (J) = Base64_Filler); end loop; Last := I - 1; exit; end if; end loop; return Result (Result'First .. Last); end Encode_Base64; function Encode_Base64 (Data : in Atom; Digit_62, Digit_63, Padding : in Octet) return Atom is Result : Atom := Encode_Base64 (Data); begin for I in Result'Range loop if Result (I) = Plus then Result (I) := Digit_62; elsif Result (I) = Slash then Result (I) := Digit_63; elsif Result (I) = Base64_Filler then Result (I) := Padding; end if; end loop; return Result; end Encode_Base64; end Natools.S_Expressions.Encodings; |
Modified src/natools-s_expressions-encodings.ads from [37bb5afca8] to [a5e369092e].
︙ | ︙ | |||
97 98 99 100 101 102 103 104 | function Encode_Base64 (Value : in Octet) return Octet; procedure Encode_Base64 (Output : out Atom; A : in Octet); procedure Encode_Base64 (Output : out Atom; A, B : in Octet); procedure Encode_Base64 (Output : out Atom; A, B, C : in Octet); function Encode_Base64 (Data : in Atom) return Atom; end Natools.S_Expressions.Encodings; | > > > > > > > > > > > > > > > > > > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | function Encode_Base64 (Value : in Octet) return Octet; procedure Encode_Base64 (Output : out Atom; A : in Octet); procedure Encode_Base64 (Output : out Atom; A, B : in Octet); procedure Encode_Base64 (Output : out Atom; A, B, C : in Octet); function Encode_Base64 (Data : in Atom) return Atom; --------------------------------- -- Base-64 with other charsets -- --------------------------------- function Decode_Base64 (Data : in Atom; Digit_62, Digit_63 : in Octet) return Atom; function Encode_Base64 (Data : in Atom; Digit_62, Digit_63 : in Octet) return Atom; -- Paddingless encoding function Encode_Base64 (Data : in Atom; Digit_62, Digit_63, Padding : in Octet) return Atom; end Natools.S_Expressions.Encodings; |