… | |
… | |
246 | If C<$enable> is false (the default), then C<encode> will encode strings |
246 | If C<$enable> is false (the default), then C<encode> will encode strings |
247 | the standard CBOR way. |
247 | the standard CBOR way. |
248 | |
248 | |
249 | This option does not affect C<decode> in any way - string references will |
249 | This option does not affect C<decode> in any way - string references will |
250 | always be decoded properly if present. |
250 | always be decoded properly if present. |
|
|
251 | |
|
|
252 | =item $cbor = $cbor->text_keys ([$enable]) |
|
|
253 | |
|
|
254 | =item $enabled = $cbor->get_text_keys |
|
|
255 | |
|
|
256 | If C<$enabled> is true (or missing), then C<encode> will encode all |
|
|
257 | perl hash keys as CBOR text strings/UTF-8 string, upgrading them as needed. |
|
|
258 | |
|
|
259 | If C<$enable> is false (the default), then C<encode> will encode hash keys |
|
|
260 | normally - upgraded perl strings (strings internally encoded as UTF-8) as |
|
|
261 | CBOR text strings, and downgraded perl strings as CBOR byte strings. |
|
|
262 | |
|
|
263 | This option does not affect C<decode> in any way. |
|
|
264 | |
|
|
265 | This option is useful for interoperability with CBOR decoders that don't |
|
|
266 | treat byte strings as a form of text. It is especially useful as Perl |
|
|
267 | gives very little control over hash keys. |
|
|
268 | |
|
|
269 | Enabling this option can be slow, as all downgraded hash keys that are |
|
|
270 | encoded need to be scanned and converted to UTF-8. |
|
|
271 | |
|
|
272 | =item $cbor = $cbor->text_strings ([$enable]) |
|
|
273 | |
|
|
274 | =item $enabled = $cbor->get_text_strings |
|
|
275 | |
|
|
276 | This option works similar to C<text_keys>, above, but works on all strings |
|
|
277 | (including hash keys), so C<text_keys> has no further effect after |
|
|
278 | enabling C<text_strings>. |
|
|
279 | |
|
|
280 | If C<$enabled> is true (or missing), then C<encode> will encode all perl |
|
|
281 | strings as CBOR text strings/UTF-8 strings, upgrading them as needed. |
|
|
282 | |
|
|
283 | If C<$enable> is false (the default), then C<encode> will encode strings |
|
|
284 | normally (but see C<text_keys>) - upgraded perl strings (strings |
|
|
285 | internally encoded as UTF-8) as CBOR text strings, and downgraded perl |
|
|
286 | strings as CBOR byte strings. |
|
|
287 | |
|
|
288 | This option does not affect C<decode> in any way. |
|
|
289 | |
|
|
290 | This option has similar advantages and disadvantages as C<text_keys>. In |
|
|
291 | addition, this option effectively removes the ability to encode byte |
|
|
292 | strings, which might break some C<FREEZE> and C<TO_CBOR> methods that rely |
|
|
293 | on this, such as bignum encoding, so this option is mainly useful for very |
|
|
294 | simple data. |
251 | |
295 | |
252 | =item $cbor = $cbor->validate_utf8 ([$enable]) |
296 | =item $cbor = $cbor->validate_utf8 ([$enable]) |
253 | |
297 | |
254 | =item $enabled = $cbor->get_validate_utf8 |
298 | =item $enabled = $cbor->get_validate_utf8 |
255 | |
299 | |
… | |
… | |
663 | "$self" # encode url string |
707 | "$self" # encode url string |
664 | } |
708 | } |
665 | |
709 | |
666 | sub URI::THAW { |
710 | sub URI::THAW { |
667 | my ($class, $serialiser, $uri) = @_; |
711 | my ($class, $serialiser, $uri) = @_; |
668 | |
|
|
669 | $class->new ($uri) |
712 | $class->new ($uri) |
670 | } |
713 | } |
671 | |
714 | |
672 | Unlike C<TO_CBOR>, multiple values can be returned by C<FREEZE>. For |
715 | Unlike C<TO_CBOR>, multiple values can be returned by C<FREEZE>. For |
673 | example, a C<FREEZE> method that returns "type", "id" and "variant" values |
716 | example, a C<FREEZE> method that returns "type", "id" and "variant" values |