|
rpm-build |
0f2925 |
(*
|
|
rpm-build |
0f2925 |
* UChar - Unicode (ISO-UCS) characters
|
|
rpm-build |
0f2925 |
* Copyright (C) 2002, 2003 Yamagata Yoriyuki
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is free software; you can redistribute it and/or
|
|
rpm-build |
0f2925 |
* modify it under the terms of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License as published by the Free Software Foundation; either
|
|
rpm-build |
0f2925 |
* version 2.1 of the License, or (at your option) any later version,
|
|
rpm-build |
0f2925 |
* with the special exception on linking described in file LICENSE.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is distributed in the hope that it will be useful,
|
|
rpm-build |
0f2925 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rpm-build |
0f2925 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
rpm-build |
0f2925 |
* Lesser General Public License for more details.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* You should have received a copy of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License along with this library; if not, write to the Free Software
|
|
rpm-build |
0f2925 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
rpm-build |
0f2925 |
*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
type t = int
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
exception Out_of_range
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
external unsafe_chr_of_uint : int -> t = "%identity"
|
|
rpm-build |
0f2925 |
external uint_code : t -> int = "%identity"
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let char_of c =
|
|
rpm-build |
0f2925 |
if c >= 0 && c < 0x100 then Char.chr c else raise Out_of_range
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let of_char = Char.code
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let code c = if c >= 0 then c else raise Out_of_range
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let chr n =
|
|
rpm-build |
0f2925 |
if n >= 0 && n lsr 31 = 0 then n else invalid_arg "UChar.chr"
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let chr_of_uint n = if n lsr 31 = 0 then n else invalid_arg "UChar.uint_chr"
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let eq (u1 : t) (u2 : t) = u1 = u2
|
|
rpm-build |
0f2925 |
let compare u1 u2 =
|
|
rpm-build |
0f2925 |
let sgn = (u1 lsr 16) - (u2 lsr 16) in
|
|
rpm-build |
0f2925 |
if sgn = 0 then (u1 land 0xFFFF) - (u2 land 0xFFFF) else sgn
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
type uchar = t
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let int_of_uchar u = uint_code u
|
|
rpm-build |
0f2925 |
let uchar_of_int n = chr_of_uint n
|