<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue',
Helvetica, Arial, sans-serif; font-size: 14.3000001907349px;
font-style: normal; font-variant: normal; font-weight: bold;
letter-spacing: normal; line-height: 20.4285717010498px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; display: inline !important; float:
none; background-color: rgb(255, 255, 255);">$json =
$json->utf8 ([$enable])<br>
</span><br>
<span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue',
Helvetica, Arial, sans-serif; font-size: 14.3000001907349px;
font-style: normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: 20.4285717010498px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; display: inline !important; float:
none; background-color: rgb(255, 255, 255);">If<span
class="Apple-converted-space"> </span></span><code
style="box-sizing: border-box; font-family: Menlo, Monaco, 'DejaVu
Sans Mono', Consolas, 'Bitstream Vera Sans Mono', Courier,
'Courier New', monospace; font-size: 12.8699998855591px; padding:
2px 4px; color: rgb(51, 51, 51); white-space: normal;
border-radius: 4px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; orphans: auto;
text-align: start; text-indent: 0px; text-transform: none; widows:
1; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(245, 245, 245);">$enable</code><span
style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue',
Helvetica, Arial, sans-serif; font-size: 14.3000001907349px;
font-style: normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: 20.4285717010498px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; display: inline !important; float:
none; background-color: rgb(255, 255, 255);"><span
class="Apple-converted-space"> </span>is true (or missing), then
the<span class="Apple-converted-space"> </span></span><code
style="box-sizing: border-box; font-family: Menlo, Monaco, 'DejaVu
Sans Mono', Consolas, 'Bitstream Vera Sans Mono', Courier,
'Courier New', monospace; font-size: 12.8699998855591px; padding:
2px 4px; color: rgb(51, 51, 51); white-space: normal;
border-radius: 4px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; orphans: auto;
text-align: start; text-indent: 0px; text-transform: none; widows:
1; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(245, 245, 245);">encode</code><span
style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue',
Helvetica, Arial, sans-serif; font-size: 14.3000001907349px;
font-style: normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: 20.4285717010498px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; display: inline !important; float:
none; background-color: rgb(255, 255, 255);"><span
class="Apple-converted-space"> </span>method will encode the
JSON result into UTF-8, as required by many protocols, while the<span
class="Apple-converted-space"> </span></span><code
style="box-sizing: border-box; font-family: Menlo, Monaco, 'DejaVu
Sans Mono', Consolas, 'Bitstream Vera Sans Mono', Courier,
'Courier New', monospace; font-size: 12.8699998855591px; padding:
2px 4px; color: rgb(51, 51, 51); white-space: normal;
border-radius: 4px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; orphans: auto;
text-align: start; text-indent: 0px; text-transform: none; widows:
1; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(245, 245, 245);">decode</code><span
style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue',
Helvetica, Arial, sans-serif; font-size: 14.3000001907349px;
font-style: normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: 20.4285717010498px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; display: inline !important; float:
none; background-color: rgb(255, 255, 255);"><span
class="Apple-converted-space"> </span>method expects to be
handled an UTF-8-encoded string. Please note that UTF-8-encoded
strings do not contain any characters outside the range<span
class="Apple-converted-space"> </span></span><code
style="box-sizing: border-box; font-family: Menlo, Monaco, 'DejaVu
Sans Mono', Consolas, 'Bitstream Vera Sans Mono', Courier,
'Courier New', monospace; font-size: 12.8699998855591px; padding:
2px 4px; color: rgb(51, 51, 51); white-space: normal;
border-radius: 4px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; orphans: auto;
text-align: start; text-indent: 0px; text-transform: none; widows:
1; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(245, 245, 245);">0..255</code><span
style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue',
Helvetica, Arial, sans-serif; font-size: 14.3000001907349px;
font-style: normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: 20.4285717010498px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; display: inline !important; float:
none; background-color: rgb(255, 255, 255);">, they are thus
useful for bytewise/binary I/O.<br>
<br>
</span>
<div class="moz-cite-prefix">Видимо, я неправильно понимал что есть
utf8 encoded string - по этому описанию получается, это utf8
encoded string есть последовательность байтиков без флага utf8 (и
тесты с utf8::is_utf8 это предположение подтверждают).<br>
<br>
Почему это называется "encode the JSON result <b>into UTF-8</b>"
когда оно наоборот в байтики?<br>
<br>
И непонятным остается "as required by many protocols" - ни разу не
видел, чтобы какое-то апи или протокол требовали юникод ввиде
байтиков вместо юникода. <br>
<br>
<br>
01.04.2015 15:31, Nick Knutov пишет:<br>
</div>
<blockquote cite="mid:551BC90C.5020203@knutov.com" type="cite">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
utf8::all в дансере (и не только в нем) нужен, например, чтобы
избежать "Wide character in print" во всевозможных местах, и при
этом получать везде строчки в юникоде, а не ввиде \x{123}.<br>
<br>
И, судя по всему, двойное кодирование происходит (или может
происходить) и без utf8::all.<br>
<br>
Например, если никаких utf8/utf8::all нет и я использую родной
from_json, а в конфиге для json включен utf8<br>
<br>
engines:<br>
JSON:<br>
utf8: '1'<br>
<br>
и в хеше - уже юникод с флагом, что оно юникод, то<br>
<br>
return to_json $ha;<br>
<br>
гарантированно ломает юникод. Я уже начинаю сомневаться, правильно
ли я понимаю в документации описание флага utf8 в json, потому
что, получается, с ним всегда происходит еще одно кодирование, что
явно не является желаемым поведением по умолчанию, однако
encode_json - это именно <code class="perl plain"
style="box-sizing: content-box !important; font-family: inherit
!important; font-size: 12px; padding: 0px !important; color:
black !important; white-space: pre; border-radius: 0px
!important; border: 0px !important; bottom: auto !important;
float: none !important; height: auto !important; left: auto
!important; line-height: normal; margin: 0px !important;
outline: 0px !important; overflow: visible !important; position:
static !important; right: auto !important; text-align: left;
top: auto !important; vertical-align: baseline !important;
width: auto !important; font-weight: normal; font-style: normal;
min-height: inherit !important; font-variant: normal;
letter-spacing: normal; orphans: auto; text-indent: 0px;
text-transform: none; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-image: none
!important; background-attachment: initial !important;
background-color: rgb(245, 245, 245); background-size: initial
!important; background-origin: initial !important;
background-clip: initial !important; background-position:
initial !important; background-repeat: initial !important;">JSON::XS->new->utf8->encode
(</code><code class="perl variable" style="box-sizing:
content-box !important; font-family: inherit !important;
font-size: 12px; padding: 0px !important; color: rgb(170, 119,
0) !important; white-space: pre; border-radius: 0px !important;
border: 0px !important; bottom: auto !important; float: none
!important; height: auto !important; left: auto !important;
line-height: normal; margin: 0px !important; outline: 0px
!important; overflow: visible !important; position: static
!important; right: auto !important; text-align: left; top: auto
!important; vertical-align: baseline !important; width: auto
!important; font-weight: normal; font-style: normal; min-height:
inherit !important; font-variant: normal; letter-spacing:
normal; orphans: auto; text-indent: 0px; text-transform: none;
widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-image: none !important; background-attachment:
initial !important; background-color: rgb(245, 245, 245);
background-size: initial !important; background-origin: initial
!important; background-clip: initial !important;
background-position: initial !important; background-repeat:
initial !important;">$perl_scalar</code><code class="perl plain"
style="box-sizing: content-box !important; font-family: inherit
!important; font-size: 12px; padding: 0px !important; color:
black !important; white-space: pre; border-radius: 0px
!important; border: 0px !important; bottom: auto !important;
float: none !important; height: auto !important; left: auto
!important; line-height: normal; margin: 0px !important;
outline: 0px !important; overflow: visible !important; position:
static !important; right: auto !important; text-align: left;
top: auto !important; vertical-align: baseline !important;
width: auto !important; font-weight: normal; font-style: normal;
min-height: inherit !important; font-variant: normal;
letter-spacing: normal; orphans: auto; text-indent: 0px;
text-transform: none; widows: 1; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-image: none
!important; background-attachment: initial !important;
background-color: rgb(245, 245, 245); background-size: initial
!important; background-origin: initial !important;
background-clip: initial !important; background-position:
initial !important; background-repeat: initial !important;">)</code><br>
<br>
<br>
ps: Dancer::Serializer - это совсем про другое.<br>
<br>
<br>
<div class="moz-cite-prefix">01.04.2015 15:16, Maxim Vuets пишет:<br>
</div>
<blockquote
cite="mid:CAG6DbojOaeeiEgn9TFR4Vib8221KqpxGMhJ0RhRfenwFZj1WyQ@mail.gmail.com"
type="cite">
<pre wrap="">2015-04-01 12:06 GMT+02:00 Nick Knutov <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:mail@knutov.com"><mail@knutov.com></a>:
</pre>
<blockquote type="cite">
<pre wrap="">Если из-за utf8::all или неизвестно чего еще в фреймворке где-то происходит
</pre>
</blockquote>
<pre wrap="">Настоятельно не рекомендую использовать utf8::all в Дансере. Опять же,
не знаю за первый, но второй сам включает эти штуки (я говорил об этом
в прошлом ответе). Чревато плохими побочными эффектами. Используя
Дансер, нужно играть по его правилам.
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Best Regards,
Nick Knutov
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://knutov.com">http://knutov.com</a>
ICQ: 272873706
Voice: +7-904-84-23-130 </pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Best Regards,
Nick Knutov
<a class="moz-txt-link-freetext" href="http://knutov.com">http://knutov.com</a>
ICQ: 272873706
Voice: +7-904-84-23-130 </pre>
</body>
</html>