<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-03-08 2:34 GMT+03:00 Ron Garret <span dir="ltr"><<a href="mailto:ron@flownet.com" target="_blank">ron@flownet.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br>
On Mar 7, 2016, at 3:23 PM, Gary Byers <<a href="mailto:gb@clozure.com">gb@clozure.com</a>> wrote:<br>
<br>
><br>
><br>
> On 03/07/2016 03:36 PM, Ron Garret wrote:<br>
>> On Mar 7, 2016, at 1:30 PM, R. Matthew Emerson <<a href="mailto:rme@clozure.com">rme@clozure.com</a>> wrote:<br>
>><br>
>>>> On Mar 5, 2016, at 12:03 PM, Ron Garret <<a href="mailto:ron@flownet.com">ron@flownet.com</a>> wrote:<br>
>>>><br>
>>>><br>
>>>> On Mar 5, 2016, at 8:39 AM, Dmitry Igrishin <<a href="mailto:dfigrish@gmail.com">dfigrish@gmail.com</a>> wrote:<br>
>>>><br>
>>>>><br>
>>>>> 2016-03-05 16:25 GMT+03:00 Dmitry Igrishin <<a href="mailto:dfigrish@gmail.com">dfigrish@gmail.com</a>>:<br>
>>>>> Hello,<br>
>>>>><br>
>>>>> The *default-external-parameter* doesn't considered by<br>
>>>>> count-characters-in-octet-vector, decode-string-from-octets,<br>
>>>>> encode-string-to-octets, string-size-in-octets functions which<br>
>>>>> has the :external-format parameter. I believe that<br>
>>>>> *default-external-parameter* should affect the behaviour of<br>
>>>>> all functions with :external-format parameter, right?<br>
>>>>> Sorry, I meant the *default-external-format* special variable...<br>
>>>> This is a bug in ccl::lookup-character-encoding.  Here’s a patch:<br>
>>>><br>
>>>> (in-package :ccl)<br>
>>>><br>
>>>> (let ((ccl::*warn-if-redefine-kernel* nil))<br>
>>>>  (defun lookup-character-encoding (name)<br>
>>>>    (gethash (or name *default-external-format*) *character-encodings*)))<br>
>>> I don't think I can apply this.<br>
>>><br>
>>> The issue is that nil is a valid character encoding name: it's a documented synonym for :iso-8859-1.<br>
>> That’s a bug in the documentation.  NIL should be a synonym for *default-character-encoding*.  (I’m not joking.  That part of the docs was written before the introduction of *default-character-encoding*.)<br>
> when that part (what part is it, by the way?) was written, :iso-8859-1 was the default character encoding.<br>
<br>
</span>Yes, I know.  That’s why I thought it was wrong, because the introduction of *default-external-format* had rendered it obsolete.  But then I read it more closely and remembered my history...<br>
<span class=""><br>
> Changing the functions in question to use (e.g.)<br>
><br>
> (defun encode-string-to-octets (string &key (external-format :default) ....) ...<br>
><br>
> seems to be another approach<br>
<br>
</span>Yes, just more work.<br>
<span class=""><br>
> I suspect (but don't claim to know) that most uses of things like ENCODE-STRING-TO-OCTETS involve an explicit<br>
> :EXTERNAL-FORMAT argument.<br>
<br>
</span>As one who believes that UTF-8 is the One True Encoding, I have:<br>
<br>
(setf *default-external-format* :utf-8)<br>
<br>
in my ccl-init file, and I never pass an explicit argument to ENCODE-STRING-TO-OCTETS.  I consider anything that doesn’t work under those circumstances to be a bug.  But I also don’t really care that much because it’s so easy to just patch or wrap things that don’t work the way I want them to.  So personally I think it’s not entirely unreasonable to just leave things the way they are.  It depends on how much value you want to put on adhering to the principle of least surprise for new users (though with CL that ship did sail a long, long time ago).<br></blockquote><div>The current behaviour was surprising indeed after reading the documentation</div><div>about the ccl:*default-external-format* which says:</div><div><br></div><div>"The value of this variable is used when :external-format is unspecified or specified as :default."</div><div><br></div><div>Well, I leave the :external-format unspecified and got the wrong result:</div><div><br></div><div><div>CL-USER> (decode-string-from-octets (encode-string-to-octets "лисп"))</div><div>"^Z^Z^Z^Z"</div><div>4</div></div><div><div><br></div></div></div></div></div>