12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273# 2 "char.ml"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)open!Stdlib[@@@ocaml.flambda_o3](* Character operations *)externalcode:char->int@@portable="%identity"externalunsafe_chr:int->char@@portable="%identity"letchrn=ifn<0||n>255theninvalid_arg"Char.chr"elseunsafe_chrnexternalbytes_create:int->bytes@@portable="caml_create_bytes"externalbytes_unsafe_set:bytes->int->char->unit@@portable="%bytes_unsafe_set"externalunsafe_to_string:bytes->string@@portable="%bytes_to_string"letescaped=function|'\''->"\\'"|'\\'->"\\\\"|'\n'->"\\n"|'\t'->"\\t"|'\r'->"\\r"|'\b'->"\\b"|' '..'~'asc->lets=bytes_create1inbytes_unsafe_sets0c;unsafe_to_strings|c->letn=codecinlets=bytes_create4inbytes_unsafe_sets0'\\';bytes_unsafe_sets1(unsafe_chr(48+n/100));bytes_unsafe_sets2(unsafe_chr(48+(n/10)mod10));bytes_unsafe_sets3(unsafe_chr(48+nmod10));unsafe_to_stringsletlowercase_ascii=function|'A'..'Z'asc->unsafe_chr(codec+32)|c->cletuppercase_ascii=function|'a'..'z'asc->unsafe_chr(codec-32)|c->ctypet=charletcomparec1c2=codec1-codec2letequal(c1:t)(c2:t)=comparec1c2=0(* [caml_hash_exn] doesn't raise on chars, so it's safe for
it to be marked as [@@noalloc].
*)externalseeded_hash_param:int->int->int->char->int@@portable="caml_hash_exn"[@@noalloc]letseeded_hashseedx=seeded_hash_param10100seedxlethashx=seeded_hash_param101000x