… | |
… | |
200 | the standard CBOR way. |
200 | the standard CBOR way. |
201 | |
201 | |
202 | This option does not affect "decode" in any way - string references |
202 | This option does not affect "decode" in any way - string references |
203 | will always be decoded properly if present. |
203 | will always be decoded properly if present. |
204 | |
204 | |
|
|
205 | $cbor = $cbor->validate_utf8 ([$enable]) |
|
|
206 | $enabled = $cbor->get_validate_utf8 |
|
|
207 | If $enable is true (or missing), then "decode" will validate that |
|
|
208 | elements (text strings) containing UTF-8 data in fact contain valid |
|
|
209 | UTF-8 data (instead of blindly accepting it). This validation |
|
|
210 | obviously takes extra time during decoding. |
|
|
211 | |
|
|
212 | The concept of "valid UTF-8" used is perl's concept, which is a |
|
|
213 | superset of the official UTF-8. |
|
|
214 | |
|
|
215 | If $enable is false (the default), then "decode" will blindly accept |
|
|
216 | UTF-8 data, marking them as valid UTF-8 in the resulting data |
|
|
217 | structure regardless of whether thats true or not. |
|
|
218 | |
|
|
219 | Perl isn't too happy about corrupted UTF-8 in strings, but should |
|
|
220 | generally not crash or do similarly evil things. Extensions might be |
|
|
221 | not so forgiving, so it's recommended to turn on this setting if you |
|
|
222 | receive untrusted CBOR. |
|
|
223 | |
|
|
224 | This option does not affect "encode" in any way - strings that are |
|
|
225 | supposedly valid UTF-8 will simply be dumped into the resulting CBOR |
|
|
226 | string without checking whether that is, in fact, true or not. |
|
|
227 | |
205 | $cbor = $cbor->filter ([$cb->($tag, $value)]) |
228 | $cbor = $cbor->filter ([$cb->($tag, $value)]) |
206 | $cb_or_undef = $cbor->get_filter |
229 | $cb_or_undef = $cbor->get_filter |
207 | Sets or replaces the tagged value decoding filter (when $cb is |
230 | Sets or replaces the tagged value decoding filter (when $cb is |
208 | specified) or clears the filter (if no argument or "undef" is |
231 | specified) or clears the filter (if no argument or "undef" is |
209 | provided). |
232 | provided). |
… | |
… | |
653 | |
676 | |
654 | When any of these need to load additional modules that are not part of |
677 | When any of these need to load additional modules that are not part of |
655 | the perl core distribution (e.g. URI), it is (currently) up to the user |
678 | the perl core distribution (e.g. URI), it is (currently) up to the user |
656 | to provide these modules. The decoding usually fails with an exception |
679 | to provide these modules. The decoding usually fails with an exception |
657 | if the required module cannot be loaded. |
680 | if the required module cannot be loaded. |
|
|
681 | |
|
|
682 | 0, 1 (date/time string, seconds since the epoch) |
|
|
683 | These tags are decoded into Time::Piece objects. The corresponding |
|
|
684 | "Time::Piece::TO_CBOR" method always encodes into tag 1 values |
|
|
685 | currently. |
|
|
686 | |
|
|
687 | The Time::Piece API is generally surprisingly bad, and fractional |
|
|
688 | seconds are only accidentally kept intact, so watch out. On the plus |
|
|
689 | side, the module comes with perl since 5.10, which has to count for |
|
|
690 | something. |
658 | |
691 | |
659 | 2, 3 (positive/negative bignum) |
692 | 2, 3 (positive/negative bignum) |
660 | These tags are decoded into Math::BigInt objects. The corresponding |
693 | These tags are decoded into Math::BigInt objects. The corresponding |
661 | "Math::BigInt::TO_CBOR" method encodes "small" bigints into normal |
694 | "Math::BigInt::TO_CBOR" method encodes "small" bigints into normal |
662 | CBOR integers, and others into positive/negative CBOR bignums. |
695 | CBOR integers, and others into positive/negative CBOR bignums. |