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

NAME

6       Bytes - Byte sequence operations.
7

Module

9       Module   Bytes
10

Documentation

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