[m-dev.] Binary data and UTF-8
Peter Ross
pro at missioncriticalit.com
Mon May 14 16:53:39 AEST 2012
On 14 May 2012 05:22, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Fri, 11 May 2012, Peter Wang wrote:
>
>> On Fri, 11 May 2012 14:00:41 +1000 (EST), Julien Fischer
>> <juliensf at csse.unimelb.edu.au> wrote:
>>>
>>>
>>> On Fri, 11 May 2012, Peter Wang wrote:
>>>
>>>> And my general complaint: working with bits is annoying and error prone.
>>>> We don't necessarily need a new type, just a module that provides a
>>>> byte-oriented interface on top of bitmap.
>>>
>>>
>>> Isn't there already a byte-orinted interface on top of it?
>>
>>
>> Not for these.
>>
>> :- func init(num_bits::in, bool::in) = (bitmap::bitmap_uo) is det.
>> :- func init(num_bits::in) = (bitmap::bitmap_uo) is det.
>> :- func resize(bitmap, num_bits, bool) = bitmap.
>> :- func shrink_without_copying(bitmap, num_bits) = bitmap.
>>
>> Some of the bit versions have taken the obvious names, and nothing
>> prevents me calling those by accident, e.g. those above, in_range,
>> slice.
>>
>> Other obvious names that are unusable:
>>
>> :- func size(bitmap) = num_bytes.
>> :- pred get(bitmap, int, byte).
>> :- pred set(int, byte, bitmap, bitmap).
>
>
> That's a fair point - perhaps we should just add a byte_array module
> to the standard lib and be done with it.
>
That's what we use at MC. Find attached the code that we use for
binary streams at MC. We're haapy to assign copyright to the Mercury
group and have them integrated in the standard library.
Pete
-------------- next part --------------
A non-text attachment was scrubbed...
Name: byte_buffer.m
Type: application/octet-stream
Size: 39712 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20120514/837faa0a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: blob.m
Type: application/octet-stream
Size: 4552 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20120514/837faa0a/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin_stream.m
Type: application/octet-stream
Size: 5552 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20120514/837faa0a/attachment-0002.obj>
More information about the developers
mailing list