> On 18 Sep 2018, at 11:04, Guillermo Polito <[email protected]> wrote:
> 
> 
> 
> On Tue, Sep 18, 2018 at 10:43 AM Henrik Sperre Johansen 
> <[email protected] <mailto:[email protected]>> wrote:
> Guillermo Polito wrote
> > On Mon, Sep 17, 2018 at 6:52 PM Alistair Grant &lt;
> 
> > akgrant0710@
> 
> > &gt;
> > wrote:
> > 
> >> Hi Esteban, Guille and Everyone,
> >>
> >> I haven't looked at using FFI much, however it is easy to imagine that
> >> different file encoding rules on different platforms will make writing
> >> FFI calls more difficult,
> > 
> > 
> > Well not really (from my point of view :))
> > From the point of view of the FFI call an encoded string is just a bunch
> > of
> > bytes. FFI does not do any interpretation of them.
> 
> It *would* be pretty handy for adding some auto-conversion into the
> marshaller based on parameter encoding options though... (other than
> filename, could be done in smalltalk using exisiting encoders)
> 
> self 
>     ffiCall: #(bool saveContentsToFile(String fileName, String contents)) 
>     options: #(+stringEncodings( fileName return , platformAPI contents)
> 
> Well, I like this idea. 
> 
> (And yes, I've probably badly mangled the options syntax)
> 
> Is much less verbose than having to manually convert Strings to the proper
> platform Unicode encodings before calling.
> Depends a bit on whether the primitive argument is
> Byte/Widestrings(latin1/utf32), or if it accepts only utf8 bytes and one has
> to convert first anyways.
> 
> It's not like this isn't a pain point, there are plenty of currently used
> API's that are broken if you try to use non-ascii.
> 
> Yes, but I think this may be because in general people tend to not know how 
> encodings work... (even myself I don't feel I know enough :))
> But this makes me think that we should make encoding explicit?

Yup, explicit please. Nothing hide behind the carpet :)

> 
> Maybe we should force people to specify an encoding if they specify a callout 
> using a string.
> And then, either they specify it at the level of the callout, or at the level 
> of the library (like setting a default encoding for all strings).


You can have some global FFI settings (I was thinking on adding some global 
options settings for FFI in general, btw) and even “library based settings”, to 
simplify.

Esteban

> 
> Because this raises also the question of what is the default encoding?
> And I'd say that in there is no satisfactory default encoding...

Reply via email to