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