1Stdlib.Bytes(3)                  OCaml library                 Stdlib.Bytes(3)
2
3
4

NAME

6       Stdlib.Bytes - no description
7

Module

9       Module   Stdlib.Bytes
10

Documentation

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