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   Binary encoding/decoding of integers
758       The functions in this section binary encode and decode integers to  and
759       from byte sequences.
760
761       All  following  functions raise Invalid_argument if the space needed at
762       index i to decode or encode the integer is not available.
763
764       Little-endian (resp. big-endian) encoding means that least (resp. most)
765       significant  bytes  are stored first.  Big-endian is also known as net‐
766       work byte order.  Native-endian encoding  is  either  little-endian  or
767       big-endian depending on Sys.big_endian .
768
769       32-bit  and  64-bit  integers  are  represented  by the int32 and int64
770       types, which can be interpreted either as signed or unsigned numbers.
771
772       8-bit and 16-bit integers are represented by the int  type,  which  has
773       more  bits  than  the binary encoding.  These extra bits are handled as
774       follows:
775
776       -Functions that decode signed (resp. unsigned) 8-bit or 16-bit integers
777       represented by int values sign-extend (resp. zero-extend) their result.
778
779       -Functions that encode 8-bit or 16-bit integers represented by int val‐
780       ues truncate their input to their least significant bytes.
781
782
783       val get_uint8 : bytes -> int -> int
784
785
786       get_uint8 b i is b 's unsigned 8-bit integer starting at byte index i .
787
788
789       Since 4.08
790
791
792
793       val get_int8 : bytes -> int -> int
794
795
796       get_int8 b i is b 's signed 8-bit integer starting at byte index i .
797
798
799       Since 4.08
800
801
802
803       val get_uint16_ne : bytes -> int -> int
804
805
806       get_uint16_ne b i is b 's native-endian unsigned 16-bit integer  start‐
807       ing at byte index i .
808
809
810       Since 4.08
811
812
813
814       val get_uint16_be : bytes -> int -> int
815
816
817       get_uint16_be  b  i is b 's big-endian unsigned 16-bit integer starting
818       at byte index i .
819
820
821       Since 4.08
822
823
824
825       val get_uint16_le : bytes -> int -> int
826
827
828       get_uint16_le b i is b 's little-endian unsigned 16-bit integer  start‐
829       ing at byte index i .
830
831
832       Since 4.08
833
834
835
836       val get_int16_ne : bytes -> int -> int
837
838
839       get_int16_ne  b  i is b 's native-endian signed 16-bit integer starting
840       at byte index i .
841
842
843       Since 4.08
844
845
846
847       val get_int16_be : bytes -> int -> int
848
849
850       get_int16_be b i is b 's big-endian signed 16-bit integer  starting  at
851       byte index i .
852
853
854       Since 4.08
855
856
857
858       val get_int16_le : bytes -> int -> int
859
860
861       get_int16_le  b  i is b 's little-endian signed 16-bit integer starting
862       at byte index i .
863
864
865       Since 4.08
866
867
868
869       val get_int32_ne : bytes -> int -> int32
870
871
872       get_int32_ne b i is b 's native-endian 32-bit integer starting at  byte
873       index i .
874
875
876       Since 4.08
877
878
879
880       val get_int32_be : bytes -> int -> int32
881
882
883       get_int32_be b i is b 's big-endian 32-bit integer starting at byte in‐
884       dex i .
885
886
887       Since 4.08
888
889
890
891       val get_int32_le : bytes -> int -> int32
892
893
894       get_int32_le b i is b 's little-endian 32-bit integer starting at  byte
895       index i .
896
897
898       Since 4.08
899
900
901
902       val get_int64_ne : bytes -> int -> int64
903
904
905       get_int64_ne  b i is b 's native-endian 64-bit integer starting at byte
906       index i .
907
908
909       Since 4.08
910
911
912
913       val get_int64_be : bytes -> int -> int64
914
915
916       get_int64_be b i is b 's big-endian 64-bit integer starting at byte in‐
917       dex i .
918
919
920       Since 4.08
921
922
923
924       val get_int64_le : bytes -> int -> int64
925
926
927       get_int64_le  b i is b 's little-endian 64-bit integer starting at byte
928       index i .
929
930
931       Since 4.08
932
933
934
935       val set_uint8 : bytes -> int -> int -> unit
936
937
938       set_uint8 b i v sets b 's unsigned 8-bit integer starting at byte index
939       i to v .
940
941
942       Since 4.08
943
944
945
946       val set_int8 : bytes -> int -> int -> unit
947
948
949       set_int8  b i v sets b 's signed 8-bit integer starting at byte index i
950       to v .
951
952
953       Since 4.08
954
955
956
957       val set_uint16_ne : bytes -> int -> int -> unit
958
959
960       set_uint16_ne b i v sets b 's  native-endian  unsigned  16-bit  integer
961       starting at byte index i to v .
962
963
964       Since 4.08
965
966
967
968       val set_uint16_be : bytes -> int -> int -> unit
969
970
971       set_uint16_be b i v sets b 's big-endian unsigned 16-bit integer start‐
972       ing at byte index i to v .
973
974
975       Since 4.08
976
977
978
979       val set_uint16_le : bytes -> int -> int -> unit
980
981
982       set_uint16_le b i v sets b 's  little-endian  unsigned  16-bit  integer
983       starting at byte index i to v .
984
985
986       Since 4.08
987
988
989
990       val set_int16_ne : bytes -> int -> int -> unit
991
992
993       set_int16_ne b i v sets b 's native-endian signed 16-bit integer start‐
994       ing at byte index i to v .
995
996
997       Since 4.08
998
999
1000
1001       val set_int16_be : bytes -> int -> int -> unit
1002
1003
1004       set_int16_be b i v sets b 's big-endian signed 16-bit integer  starting
1005       at byte index i to v .
1006
1007
1008       Since 4.08
1009
1010
1011
1012       val set_int16_le : bytes -> int -> int -> unit
1013
1014
1015       set_int16_le b i v sets b 's little-endian signed 16-bit integer start‐
1016       ing at byte index i to v .
1017
1018
1019       Since 4.08
1020
1021
1022
1023       val set_int32_ne : bytes -> int -> int32 -> unit
1024
1025
1026       set_int32_ne b i v sets b 's native-endian 32-bit integer  starting  at
1027       byte index i to v .
1028
1029
1030       Since 4.08
1031
1032
1033
1034       val set_int32_be : bytes -> int -> int32 -> unit
1035
1036
1037       set_int32_be b i v sets b 's big-endian 32-bit integer starting at byte
1038       index i to v .
1039
1040
1041       Since 4.08
1042
1043
1044
1045       val set_int32_le : bytes -> int -> int32 -> unit
1046
1047
1048       set_int32_le b i v sets b 's little-endian 32-bit integer  starting  at
1049       byte index i to v .
1050
1051
1052       Since 4.08
1053
1054
1055
1056       val set_int64_ne : bytes -> int -> int64 -> unit
1057
1058
1059       set_int64_ne  b  i v sets b 's native-endian 64-bit integer starting at
1060       byte index i to v .
1061
1062
1063       Since 4.08
1064
1065
1066
1067       val set_int64_be : bytes -> int -> int64 -> unit
1068
1069
1070       set_int64_be b i v sets b 's big-endian 64-bit integer starting at byte
1071       index i to v .
1072
1073
1074       Since 4.08
1075
1076
1077
1078       val set_int64_le : bytes -> int -> int64 -> unit
1079
1080
1081       set_int64_le  b  i v sets b 's little-endian 64-bit integer starting at
1082       byte index i to v .
1083
1084
1085       Since 4.08
1086
1087
1088
1089
1090
1091OCamldoc                          2022-02-04                   Stdlib.Bytes(3)
Impressum