1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374(**************************************************************************)(* *)(* 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. *)(* *)(**************************************************************************)(* Character operations *)externalcode:char->int="%identity"externalunsafe_chr:int->char="%identity"letchrn=ifn<0||n>255theninvalid_arg"Char.chr"elseunsafe_chrnexternalbytes_create:int->bytes="caml_create_bytes"externalbytes_unsafe_set:bytes->int->char->unit="%bytes_unsafe_set"externalunsafe_to_string:bytes->string="%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=function|'A'..'Z'|'\192'..'\214'|'\216'..'\222'asc->unsafe_chr(codec+32)|c->cletuppercase=function|'a'..'z'|'\224'..'\246'|'\248'..'\254'asc->unsafe_chr(codec-32)|c->cletlowercase_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