1BytesLabels(3)                   OCaml library                  BytesLabels(3)
2
3
4

NAME

6       BytesLabels - Byte sequence operations.
7

Module

9       Module   BytesLabels
10

Documentation

12       Module BytesLabels
13        : sig end
14
15
16       Byte sequence operations.
17
18       A   byte   sequence  is  a  mutable  data  structure  that  contains  a
19       fixed-length sequence of bytes. Each byte can be  indexed  in  constant
20       time for reading or writing.
21
22       Given a byte sequence s of length l , we can access each of the l bytes
23       of s via its index in the sequence. Indexes start at 0 ,  and  we  will
24       call an index valid in s if it falls within the range [0...l-1] (inclu‐
25       sive). A position is the point between two bytes or at the beginning or
26       end  of the sequence.  We call a position valid in s if it falls within
27       the range [0...l] (inclusive). Note that the byte at index n is between
28       positions n and n+1 .
29
30       Two  parameters  start and len are said to designate a valid range of s
31       if len >= 0 and start and start+len are valid positions in s .
32
33       Byte sequences can be modified in place, for instance via the  set  and
34       blit  functions  described  below.   See also strings (module String ),
35       which are almost the same data structure, but  cannot  be  modified  in
36       place.
37
38       Bytes are represented by the OCaml type char .
39
40       The labeled version of this module can be used as described in the Std‐
41       Labels module.
42
43
44       Since 4.02.0
45
46
47
48
49
50
51       val length : bytes -> int
52
53       Return the length (number of bytes) of the argument.
54
55
56
57       val get : bytes -> int -> char
58
59
60       get s n returns the byte at index n in argument s .
61
62
63       Raises Invalid_argument if n is not a valid index in s .
64
65
66
67       val set : bytes -> int -> char -> unit
68
69
70       set s n c modifies s in place, replacing the byte at index n with c .
71
72
73       Raises Invalid_argument if n is not a valid index in s .
74
75
76
77       val create : int -> bytes
78
79
80       create n returns a new byte sequence of length  n  .  The  sequence  is
81       uninitialized and contains arbitrary bytes.
82
83
84       Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
85
86
87
88       val make : int -> char -> bytes
89
90
91       make n c returns a new byte sequence of length n , filled with the byte
92       c .
93
94
95       Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
96
97
98
99       val init : int -> f:(int -> char) -> bytes
100
101
102       init n f returns a fresh byte sequence of length n , with  character  i
103       initialized to the result of f i (in increasing index order).
104
105
106       Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
107
108
109
110       val empty : bytes
111
112       A byte sequence of size 0.
113
114
115
116       val copy : bytes -> bytes
117
118       Return  a  new  byte sequence that contains the same bytes as the argu‐
119       ment.
120
121
122
123       val of_string : string -> bytes
124
125       Return a new byte sequence that contains the same bytes  as  the  given
126       string.
127
128
129
130       val to_string : bytes -> string
131
132       Return  a new string that contains the same bytes as the given byte se‐
133       quence.
134
135
136
137       val sub : bytes -> pos:int -> len:int -> bytes
138
139
140       sub s ~pos ~len returns a new byte sequence of length len ,  containing
141       the subsequence of s that starts at position pos and has length len .
142
143
144       Raises  Invalid_argument  if pos and len do not designate a valid range
145       of s .
146
147
148
149       val sub_string : bytes -> pos:int -> len:int -> string
150
151       Same as BytesLabels.sub but return a string instead of a byte sequence.
152
153
154
155       val extend : bytes -> left:int -> right:int -> bytes
156
157
158       extend s ~left ~right returns a new byte  sequence  that  contains  the
159       bytes  of  s , with left uninitialized bytes prepended and right unini‐
160       tialized bytes appended to it. If left or right is negative, then bytes
161       are removed (instead of appended) from the corresponding side of s .
162
163
164       Since 4.05.0 in BytesLabels
165
166
167       Raises Invalid_argument if the result length is negative or longer than
168       Sys.max_string_length bytes.
169
170
171
172       val fill : bytes -> pos:int -> len:int -> char -> unit
173
174
175       fill s ~pos ~len c modifies s in place, replacing len characters with c
176       , starting at pos .
177
178
179       Raises  Invalid_argument  if pos and len do not designate a valid range
180       of s .
181
182
183
184       val blit : src:bytes -> src_pos:int  ->  dst:bytes  ->  dst_pos:int  ->
185       len:int -> unit
186
187
188       blit  ~src  ~src_pos  ~dst ~dst_pos ~len copies len bytes from sequence
189       src , starting at index src_pos , to sequence dst , starting  at  index
190       dst_pos  . It works correctly even if src and dst are the same byte se‐
191       quence, and the source and destination intervals overlap.
192
193
194       Raises Invalid_argument if src_pos and len do  not  designate  a  valid
195       range  of src , or if dst_pos and len do not designate a valid range of
196       dst .
197
198
199
200       val blit_string : src:string -> src_pos:int -> dst:bytes -> dst_pos:int
201       -> len:int -> unit
202
203
204       blit  ~src ~src_pos ~dst ~dst_pos ~len copies len bytes from string src
205       , starting at index src_pos , to byte sequence dst , starting at  index
206       dst_pos .
207
208
209       Since 4.05.0 in BytesLabels
210
211
212       Raises  Invalid_argument  if  src_pos  and len do not designate a valid
213       range of src , or if dst_pos and len do not designate a valid range  of
214       dst .
215
216
217
218       val concat : sep:bytes -> bytes list -> bytes
219
220
221       concat  ~sep  sl concatenates the list of byte sequences sl , inserting
222       the separator byte sequence sep between each, and returns the result as
223       a new byte sequence.
224
225
226       Raises    Invalid_argument    if    the    result    is   longer   than
227       Sys.max_string_length bytes.
228
229
230
231       val cat : bytes -> bytes -> bytes
232
233
234       cat s1 s2 concatenates s1 and s2 and returns the result as a  new  byte
235       sequence.
236
237
238       Since 4.05.0 in BytesLabels
239
240
241       Raises    Invalid_argument    if    the    result    is   longer   than
242       Sys.max_string_length bytes.
243
244
245
246       val iter : f:(char -> unit) -> bytes -> unit
247
248
249       iter ~f s applies function f in turn to all the bytes of  s  .   It  is
250       equivalent to f (get s 0); f (get s 1); ...; f (get s
251           (length s - 1)); () .
252
253
254
255       val iteri : f:(int -> char -> unit) -> bytes -> unit
256
257       Same  as BytesLabels.iter , but the function is applied to the index of
258       the byte as first argument and the byte itself as second argument.
259
260
261
262       val map : f:(char -> char) -> bytes -> bytes
263
264
265       map ~f s applies function f in turn to all the bytes of s (in  increas‐
266       ing  index order) and stores the resulting bytes in a new sequence that
267       is returned as the result.
268
269
270
271       val mapi : f:(int -> char -> char) -> bytes -> bytes
272
273
274       mapi ~f s calls f with each character of s and its index (in increasing
275       index  order)  and stores the resulting bytes in a new sequence that is
276       returned as the result.
277
278
279
280       val fold_left : f:('a -> char -> 'a) -> init:'a -> bytes -> 'a
281
282
283       fold_left f x s computes f (... (f (f x (get s 0)) (get s 1)) ...) (get
284       s (n-1)) , where n is the length of s .
285
286
287       Since 4.13.0
288
289
290
291       val fold_right : f:(char -> 'a -> 'a) -> bytes -> init:'a -> 'a
292
293
294       fold_right  f  s  x  computes  f (get s 0) (f (get s 1) ( ... (f (get s
295       (n-1)) x) ...))  , where n is the length of s .
296
297
298       Since 4.13.0
299
300
301
302       val for_all : f:(char -> bool) -> bytes -> bool
303
304
305       for_all p s checks if all characters in s satisfy the predicate p .
306
307
308       Since 4.13.0
309
310
311
312       val exists : f:(char -> bool) -> bytes -> bool
313
314
315       exists p s checks if at least one character of s satisfies  the  predi‐
316       cate p .
317
318
319       Since 4.13.0
320
321
322
323       val trim : bytes -> bytes
324
325       Return a copy of the argument, without leading and trailing whitespace.
326       The bytes regarded as whitespace are the ASCII characters ' ' ,  '\012'
327       , '\n' , '\r' , and '\t' .
328
329
330
331       val escaped : bytes -> bytes
332
333       Return  a  copy of the argument, with special characters represented by
334       escape sequences, following the  lexical  conventions  of  OCaml.   All
335       characters  outside the ASCII printable range (32..126) are escaped, as
336       well as backslash and double-quote.
337
338
339       Raises   Invalid_argument   if    the    result    is    longer    than
340       Sys.max_string_length bytes.
341
342
343
344       val index : bytes -> char -> int
345
346
347       index s c returns the index of the first occurrence of byte c in s .
348
349
350       Raises Not_found if c does not occur in s .
351
352
353
354       val index_opt : bytes -> char -> int option
355
356
357       index_opt  s c returns the index of the first occurrence of byte c in s
358       or None if c does not occur in s .
359
360
361       Since 4.05
362
363
364
365       val rindex : bytes -> char -> int
366
367
368       rindex s c returns the index of the last occurrence of byte c in s .
369
370
371       Raises Not_found if c does not occur in s .
372
373
374
375       val rindex_opt : bytes -> char -> int option
376
377
378       rindex_opt s c returns the index of the last occurrence of byte c in  s
379       or None if c does not occur in s .
380
381
382       Since 4.05
383
384
385
386       val index_from : bytes -> int -> char -> int
387
388
389       index_from s i c returns the index of the first occurrence of byte c in
390       s after position i .  index s c is equivalent to index_from s 0 c .
391
392
393       Raises Invalid_argument if i is not a valid position in s .
394
395
396       Raises Not_found if c does not occur in s after position i .
397
398
399
400       val index_from_opt : bytes -> int -> char -> int option
401
402
403       index_from_opt s i c returns the index of the first occurrence of  byte
404       c in s after position i or None if c does not occur in s after position
405       i .  index_opt s c is equivalent to index_from_opt s 0 c .
406
407
408       Since 4.05
409
410
411       Raises Invalid_argument if i is not a valid position in s .
412
413
414
415       val rindex_from : bytes -> int -> char -> int
416
417
418       rindex_from s i c returns the index of the last occurrence of byte c in
419       s  before  position  i+1  .   rindex s c is equivalent to rindex_from s
420       (length s - 1) c .
421
422
423       Raises Invalid_argument if i+1 is not a valid position in s .
424
425
426       Raises Not_found if c does not occur in s before position i+1 .
427
428
429
430       val rindex_from_opt : bytes -> int -> char -> int option
431
432
433       rindex_from_opt s i c returns the index of the last occurrence of  byte
434       c  in s before position i+1 or None if c does not occur in s before po‐
435       sition i+1 .  rindex_opt s c is equivalent to rindex_from s (length s -
436       1) c .
437
438
439       Since 4.05
440
441
442       Raises Invalid_argument if i+1 is not a valid position in s .
443
444
445
446       val contains : bytes -> char -> bool
447
448
449       contains s c tests if byte c appears in s .
450
451
452
453       val contains_from : bytes -> int -> char -> bool
454
455
456       contains_from  s  start  c  tests if byte c appears in s after position
457       start .  contains s c is equivalent to contains_from
458           s 0 c .
459
460
461       Raises Invalid_argument if start is not a valid position in s .
462
463
464
465       val rcontains_from : bytes -> int -> char -> bool
466
467
468       rcontains_from s stop c tests if byte c appears in  s  before  position
469       stop+1 .
470
471
472       Raises  Invalid_argument  if stop < 0 or stop+1 is not a valid position
473       in s .
474
475
476
477       val uppercase : bytes -> bytes
478
479       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
480       cated.
481
482
483       Return a copy of the argument, with all lowercase letters translated to
484       uppercase, including accented letters of the ISO Latin-1 (8859-1) char‐
485       acter set.
486
487
488
489       val lowercase : bytes -> bytes
490
491       Deprecated.   Functions  operating  on Latin-1 character set are depre‐
492       cated.
493
494
495       Return a copy of the argument, with all uppercase letters translated to
496       lowercase, including accented letters of the ISO Latin-1 (8859-1) char‐
497       acter set.
498
499
500
501       val capitalize : bytes -> bytes
502
503       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
504       cated.
505
506
507       Return  a  copy of the argument, with the first character set to upper‐
508       case, using the ISO Latin-1 (8859-1) character set.
509
510
511
512       val uncapitalize : bytes -> bytes
513
514       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
515       cated.
516
517
518       Return  a  copy of the argument, with the first character set to lower‐
519       case, using the ISO Latin-1 (8859-1) character set.
520
521
522
523       val uppercase_ascii : bytes -> bytes
524
525       Return a copy of the argument, with all lowercase letters translated to
526       uppercase, using the US-ASCII character set.
527
528
529       Since 4.05.0
530
531
532
533       val lowercase_ascii : bytes -> bytes
534
535       Return a copy of the argument, with all uppercase letters translated to
536       lowercase, using the US-ASCII character set.
537
538
539       Since 4.05.0
540
541
542
543       val capitalize_ascii : bytes -> bytes
544
545       Return a copy of the argument, with the first character set  to  upper‐
546       case, using the US-ASCII character set.
547
548
549       Since 4.05.0
550
551
552
553       val uncapitalize_ascii : bytes -> bytes
554
555       Return  a  copy of the argument, with the first character set to lower‐
556       case, using the US-ASCII character set.
557
558
559       Since 4.05.0
560
561
562       type t = bytes
563
564
565       An alias for the type of byte sequences.
566
567
568
569       val compare : t -> t -> int
570
571       The comparison function for byte sequences, with the same specification
572       as  compare .  Along with the type t , this function compare allows the
573       module Bytes to be passed as argument  to  the  functors  Set.Make  and
574       Map.Make .
575
576
577
578       val equal : t -> t -> bool
579
580       The equality function for byte sequences.
581
582
583       Since 4.05.0
584
585
586
587       val starts_with : prefix:bytes -> bytes -> bool
588
589
590       starts_with ~ prefix s is true if and only if s starts with prefix .
591
592
593       Since 4.13.0
594
595
596
597       val ends_with : suffix:bytes -> bytes -> bool
598
599
600       ends_with suffix s is true if and only if s ends with suffix .
601
602
603       Since 4.13.0
604
605
606
607
608   Unsafe conversions (for advanced users)
609       This  section  describes unsafe, low-level conversion functions between
610       bytes and string . They do not copy the internal data; used improperly,
611       they  can  break  the immutability invariant on strings provided by the
612       -safe-string option. They are available for expert library authors, but
613       for   most   purposes   you  should  use  the  always-correct  BytesLa‐
614       bels.to_string and BytesLabels.of_string instead.
615
616       val unsafe_to_string : bytes -> string
617
618       Unsafely convert a byte sequence into a string.
619
620       To reason about the use of unsafe_to_string , it is convenient to  con‐
621       sider  an "ownership" discipline. A piece of code that manipulates some
622       data "owns" it; there are several disjoint ownership modes, including:
623
624       -Unique ownership: the data may be accessed and mutated
625
626       -Shared ownership: the data has several owners, that  may  only  access
627       it, not mutate it.
628
629       Unique  ownership  is linear: passing the data to another piece of code
630       means giving up ownership (we cannot write the data  again).  A  unique
631       owner  may decide to make the data shared (giving up mutation rights on
632       it), but shared data may not become uniquely-owned again.
633
634
635       unsafe_to_string s can only be used when the caller owns the  byte  se‐
636       quence  s  --  either  uniquely or as shared immutable data. The caller
637       gives up ownership of s , and gains ownership of the returned string.
638
639       There are two valid use-cases that respect this ownership discipline:
640
641       1. Creating a string by initializing and mutating a byte sequence  that
642       is never changed after initialization is performed.
643
644
645       let string_init len f : string =
646         let s = Bytes.create len in
647         for i = 0 to len - 1 do Bytes.set s i (f i) done;
648         Bytes.unsafe_to_string s
649
650
651       This  function  is  safe  because the byte sequence s will never be ac‐
652       cessed or mutated after unsafe_to_string  is  called.  The  string_init
653       code gives up ownership of s , and returns the ownership of the result‐
654       ing string to its caller.
655
656       Note that it would be unsafe if s was passed as an additional parameter
657       to the function f as it could escape this way and be mutated in the fu‐
658       ture -- string_init would give up ownership of s to pass it to f ,  and
659       could not call unsafe_to_string safely.
660
661       We have provided the String.init , String.map and String.mapi functions
662       to cover most cases of building new strings. You  should  prefer  those
663       over to_string or unsafe_to_string whenever applicable.
664
665       2.  Temporarily  giving ownership of a byte sequence to a function that
666       expects a uniquely owned string and returns ownership back, so that  we
667       can mutate the sequence again after the call ended.
668
669
670       let bytes_length (s : bytes) =
671         String.length (Bytes.unsafe_to_string s)
672
673
674       In  this use-case, we do not promise that s will never be mutated after
675       the call to bytes_length s .  The  String.length  function  temporarily
676       borrows  unique ownership of the byte sequence (and sees it as a string
677       ), but returns this ownership back to the caller, which may assume that
678       s is still a valid byte sequence after the call. Note that this is only
679       correct because we know that String.length does not capture  its  argu‐
680       ment  -- it could escape by a side-channel such as a memoization combi‐
681       nator.
682
683       The caller may not mutate s while the string is borrowed (it has tempo‐
684       rarily  given up ownership). This affects concurrent programs, but also
685       higher-order functions: if  String.length  returned  a  closure  to  be
686       called  later,  s should not be mutated until this closure is fully ap‐
687       plied and returns ownership.
688
689
690
691       val unsafe_of_string : string -> bytes
692
693       Unsafely convert a shared string to a byte sequence that should not  be
694       mutated.
695
696       The  same  ownership discipline that makes unsafe_to_string correct ap‐
697       plies to unsafe_of_string : you may use it if you were the owner of the
698       string value, and you will own the return bytes in the same mode.
699
700       In  practice,  unique ownership of string values is extremely difficult
701       to reason about correctly. You should always assume strings are shared,
702       never uniquely owned.
703
704       For  example, string literals are implicitly shared by the compiler, so
705       you never uniquely own them.
706
707
708       let incorrect = Bytes.unsafe_of_string "hello"
709       let s = Bytes.of_string "hello"
710
711
712       The first declaration is incorrect, because the string literal  "hello"
713       could  be  shared  by the compiler with other parts of the program, and
714       mutating incorrect is a bug. You must always use  the  second  version,
715       which performs a copy and is thus correct.
716
717       Assuming  unique ownership of strings that are not string literals, but
718       are (partly) built from string literals, is also incorrect.  For  exam‐
719       ple,  mutating  unsafe_of_string  ("foo"  ^  s) could mutate the shared
720       string "foo" -- assuming a rope-like representation  of  strings.  More
721       generally, functions operating on strings will assume shared ownership,
722       they do not preserve unique ownership. It is thus incorrect  to  assume
723       unique ownership of the result of unsafe_of_string .
724
725       The  only case we have reasonable confidence is safe is if the produced
726       bytes is shared -- used as an immutable byte sequence. This is possibly
727       useful  for incremental migration of low-level programs that manipulate
728       immutable sequences of bytes (for example Marshal.from_bytes ) and pre‐
729       viously used the string type for this purpose.
730
731
732
733       val split_on_char : sep:char -> bytes -> bytes list
734
735
736       split_on_char  sep  s  returns  the list of all (possibly empty) subse‐
737       quences of s that are delimited by the sep character.
738
739       The function's output is specified by the following invariants:
740
741
742       -The list is not empty.
743
744       -Concatenating its elements using sep as a separator returns a byte se‐
745       quence equal to the input ( Bytes.concat (Bytes.make 1 sep)
746             (Bytes.split_on_char sep s) = s ).
747
748       -No byte sequence in the result contains the sep character.
749
750
751
752       Since 4.13.0
753
754
755
756
757   Iterators
758       val to_seq : t -> char Seq.t
759
760       Iterate  on the string, in increasing index order. Modifications of the
761       string during iteration will be reflected in the sequence.
762
763
764       Since 4.07
765
766
767
768       val to_seqi : t -> (int * char) Seq.t
769
770       Iterate on the string, in  increasing  order,  yielding  indices  along
771       chars
772
773
774       Since 4.07
775
776
777
778       val of_seq : char Seq.t -> t
779
780       Create a string from the generator
781
782
783       Since 4.07
784
785
786
787
788   UTF codecs and validations
789   UTF-8
790       val get_utf_8_uchar : t -> int -> Uchar.utf_decode
791
792
793       get_utf_8_uchar b i decodes an UTF-8 character at index i in b .
794
795
796
797       val set_utf_8_uchar : t -> int -> Uchar.t -> int
798
799
800       set_utf_8_uchar  b  i u UTF-8 encodes u at index i in b and returns the
801       number of bytes n that were written starting at i . If n is 0 there was
802       not enough space to encode u at i and b was left untouched. Otherwise a
803       new character can be encoded at i + n .
804
805
806
807       val is_valid_utf_8 : t -> bool
808
809
810       is_valid_utf_8 b is true if and only if b contains valid UTF-8 data.
811
812
813
814
815   UTF-16BE
816       val get_utf_16be_uchar : t -> int -> Uchar.utf_decode
817
818
819       get_utf_16be_uchar b i decodes an UTF-16BE character at index i in b .
820
821
822
823       val set_utf_16be_uchar : t -> int -> Uchar.t -> int
824
825
826       set_utf_16be_uchar b i u UTF-16BE encodes u at index i in b and returns
827       the number of bytes n that were written starting at i . If n is 0 there
828       was not enough space to encode u at i and b was left untouched.  Other‐
829       wise a new character can be encoded at i + n .
830
831
832
833       val is_valid_utf_16be : t -> bool
834
835
836       is_valid_utf_16be  b  is  true if and only if b contains valid UTF-16BE
837       data.
838
839
840
841
842   UTF-16LE
843       val get_utf_16le_uchar : t -> int -> Uchar.utf_decode
844
845
846       get_utf_16le_uchar b i decodes an UTF-16LE character at index i in b .
847
848
849
850       val set_utf_16le_uchar : t -> int -> Uchar.t -> int
851
852
853       set_utf_16le_uchar b i u UTF-16LE encodes u at index i in b and returns
854       the number of bytes n that were written starting at i . If n is 0 there
855       was not enough space to encode u at i and b was left untouched.  Other‐
856       wise a new character can be encoded at i + n .
857
858
859
860       val is_valid_utf_16le : t -> bool
861
862
863       is_valid_utf_16le  b  is  true if and only if b contains valid UTF-16LE
864       data.
865
866
867
868
869   Binary encoding/decoding of integers
870       The functions in this section binary encode and decode integers to  and
871       from byte sequences.
872
873       All  following  functions raise Invalid_argument if the space needed at
874       index i to decode or encode the integer is not available.
875
876       Little-endian (resp. big-endian) encoding means that least (resp. most)
877       significant  bytes  are stored first.  Big-endian is also known as net‐
878       work byte order.  Native-endian encoding  is  either  little-endian  or
879       big-endian depending on Sys.big_endian .
880
881       32-bit  and  64-bit  integers  are  represented  by the int32 and int64
882       types, which can be interpreted either as signed or unsigned numbers.
883
884       8-bit and 16-bit integers are represented by the int  type,  which  has
885       more  bits  than  the binary encoding.  These extra bits are handled as
886       follows:
887
888       -Functions that decode signed (resp. unsigned) 8-bit or 16-bit integers
889       represented by int values sign-extend (resp. zero-extend) their result.
890
891       -Functions that encode 8-bit or 16-bit integers represented by int val‐
892       ues truncate their input to their least significant bytes.
893
894
895       val get_uint8 : bytes -> int -> int
896
897
898       get_uint8 b i is b 's unsigned 8-bit integer starting at byte index i .
899
900
901       Since 4.08
902
903
904
905       val get_int8 : bytes -> int -> int
906
907
908       get_int8 b i is b 's signed 8-bit integer starting at byte index i .
909
910
911       Since 4.08
912
913
914
915       val get_uint16_ne : bytes -> int -> int
916
917
918       get_uint16_ne b i is b 's native-endian unsigned 16-bit integer  start‐
919       ing at byte index i .
920
921
922       Since 4.08
923
924
925
926       val get_uint16_be : bytes -> int -> int
927
928
929       get_uint16_be  b  i is b 's big-endian unsigned 16-bit integer starting
930       at byte index i .
931
932
933       Since 4.08
934
935
936
937       val get_uint16_le : bytes -> int -> int
938
939
940       get_uint16_le b i is b 's little-endian unsigned 16-bit integer  start‐
941       ing at byte index i .
942
943
944       Since 4.08
945
946
947
948       val get_int16_ne : bytes -> int -> int
949
950
951       get_int16_ne  b  i is b 's native-endian signed 16-bit integer starting
952       at byte index i .
953
954
955       Since 4.08
956
957
958
959       val get_int16_be : bytes -> int -> int
960
961
962       get_int16_be b i is b 's big-endian signed 16-bit integer  starting  at
963       byte index i .
964
965
966       Since 4.08
967
968
969
970       val get_int16_le : bytes -> int -> int
971
972
973       get_int16_le  b  i is b 's little-endian signed 16-bit integer starting
974       at byte index i .
975
976
977       Since 4.08
978
979
980
981       val get_int32_ne : bytes -> int -> int32
982
983
984       get_int32_ne b i is b 's native-endian 32-bit integer starting at  byte
985       index i .
986
987
988       Since 4.08
989
990
991
992       val get_int32_be : bytes -> int -> int32
993
994
995       get_int32_be b i is b 's big-endian 32-bit integer starting at byte in‐
996       dex i .
997
998
999       Since 4.08
1000
1001
1002
1003       val get_int32_le : bytes -> int -> int32
1004
1005
1006       get_int32_le b i is b 's little-endian 32-bit integer starting at  byte
1007       index i .
1008
1009
1010       Since 4.08
1011
1012
1013
1014       val get_int64_ne : bytes -> int -> int64
1015
1016
1017       get_int64_ne  b i is b 's native-endian 64-bit integer starting at byte
1018       index i .
1019
1020
1021       Since 4.08
1022
1023
1024
1025       val get_int64_be : bytes -> int -> int64
1026
1027
1028       get_int64_be b i is b 's big-endian 64-bit integer starting at byte in‐
1029       dex i .
1030
1031
1032       Since 4.08
1033
1034
1035
1036       val get_int64_le : bytes -> int -> int64
1037
1038
1039       get_int64_le  b i is b 's little-endian 64-bit integer starting at byte
1040       index i .
1041
1042
1043       Since 4.08
1044
1045
1046
1047       val set_uint8 : bytes -> int -> int -> unit
1048
1049
1050       set_uint8 b i v sets b 's unsigned 8-bit integer starting at byte index
1051       i to v .
1052
1053
1054       Since 4.08
1055
1056
1057
1058       val set_int8 : bytes -> int -> int -> unit
1059
1060
1061       set_int8  b i v sets b 's signed 8-bit integer starting at byte index i
1062       to v .
1063
1064
1065       Since 4.08
1066
1067
1068
1069       val set_uint16_ne : bytes -> int -> int -> unit
1070
1071
1072       set_uint16_ne b i v sets b 's  native-endian  unsigned  16-bit  integer
1073       starting at byte index i to v .
1074
1075
1076       Since 4.08
1077
1078
1079
1080       val set_uint16_be : bytes -> int -> int -> unit
1081
1082
1083       set_uint16_be b i v sets b 's big-endian unsigned 16-bit integer start‐
1084       ing at byte index i to v .
1085
1086
1087       Since 4.08
1088
1089
1090
1091       val set_uint16_le : bytes -> int -> int -> unit
1092
1093
1094       set_uint16_le b i v sets b 's  little-endian  unsigned  16-bit  integer
1095       starting at byte index i to v .
1096
1097
1098       Since 4.08
1099
1100
1101
1102       val set_int16_ne : bytes -> int -> int -> unit
1103
1104
1105       set_int16_ne b i v sets b 's native-endian signed 16-bit integer start‐
1106       ing at byte index i to v .
1107
1108
1109       Since 4.08
1110
1111
1112
1113       val set_int16_be : bytes -> int -> int -> unit
1114
1115
1116       set_int16_be b i v sets b 's big-endian signed 16-bit integer  starting
1117       at byte index i to v .
1118
1119
1120       Since 4.08
1121
1122
1123
1124       val set_int16_le : bytes -> int -> int -> unit
1125
1126
1127       set_int16_le b i v sets b 's little-endian signed 16-bit integer start‐
1128       ing at byte index i to v .
1129
1130
1131       Since 4.08
1132
1133
1134
1135       val set_int32_ne : bytes -> int -> int32 -> unit
1136
1137
1138       set_int32_ne b i v sets b 's native-endian 32-bit integer  starting  at
1139       byte index i to v .
1140
1141
1142       Since 4.08
1143
1144
1145
1146       val set_int32_be : bytes -> int -> int32 -> unit
1147
1148
1149       set_int32_be b i v sets b 's big-endian 32-bit integer starting at byte
1150       index i to v .
1151
1152
1153       Since 4.08
1154
1155
1156
1157       val set_int32_le : bytes -> int -> int32 -> unit
1158
1159
1160       set_int32_le b i v sets b 's little-endian 32-bit integer  starting  at
1161       byte index i to v .
1162
1163
1164       Since 4.08
1165
1166
1167
1168       val set_int64_ne : bytes -> int -> int64 -> unit
1169
1170
1171       set_int64_ne  b  i v sets b 's native-endian 64-bit integer starting at
1172       byte index i to v .
1173
1174
1175       Since 4.08
1176
1177
1178
1179       val set_int64_be : bytes -> int -> int64 -> unit
1180
1181
1182       set_int64_be b i v sets b 's big-endian 64-bit integer starting at byte
1183       index i to v .
1184
1185
1186       Since 4.08
1187
1188
1189
1190       val set_int64_le : bytes -> int -> int64 -> unit
1191
1192
1193       set_int64_le  b  i v sets b 's little-endian 64-bit integer starting at
1194       byte index i to v .
1195
1196
1197       Since 4.08
1198
1199
1200
1201
1202
1203OCamldoc                          2022-07-22                    BytesLabels(3)
Impressum