Commit 45ffd32c authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2005-05-24 13:05:26 by afrisch] Empty log message

Original author: afrisch
Date: 2005-05-24 13:05:26+00:00
parent 3fe76a23
......@@ -22,43 +22,37 @@ struct
(i < j) &&
match s.[i] with
| '\000'..'\127' -> check s (i+1) j
| '\128'..'\223' as c->
| '\192'..'\223' as c ->
(i+1 < j) &&
let n1 = Char.code c
and n2 = Char.code s.[i+1] in
(n2 >= 128) && (n2 <= 191) &&
(((n1 land 0b11111) lsl 6) lor (n2 land 0b111111) >= 128) &&
check s (i+2) j
(n2 lsr 6 == 0b10)
&& let p = ((n1 land 0x1f) lsl 6) lor (n2 land 0x3f) in
(p >= 0x80) && (p < 0x800)
&& check s (i+2) j
| '\224'..'\239' as c ->
(i+2 < j) &&
let n1 = Char.code c
and n2 = Char.code s.[i+1]
and n3 = Char.code s.[i+2] in
(n2 >= 128) && (n2 <= 191) &&
(n3 >= 128) && (n3 <= 191) &&
let p = ((n1 land 0b1111) lsl 12) lor
((n2 land 0b111111) lsl 6) lor
(n3 land 0b111111) in
(p >= 0x800) &&
((p < 0xd800) || (p >= 0xe000)) &&
((p < 0xfffe) || (p > 0xffff)) &&
check s (i+3) j
(n2 lsr 6 == 0b10) && (n3 lsr 6 == 0b10)
&& let p = ((n1 land 0x0f) lsl 12) lor ((n2 land 0x3f) lsl 6)
lor (n3 land 0x3f) in
(p >= 0x800)
&& ((p < 0xd800) || (p >= 0xe000))
&& ((p < 0xfffe) || (p > 0xffff))
&& check s (i+3) j
| '\240'..'\247' as c ->
(i+3 < j) &&
let n1 = Char.code c
and n2 = Char.code s.[i+1]
and n3 = Char.code s.[i+2]
and n4 = Char.code s.[i+3] in
(n2 >= 128) && (n2 <= 191) &&
(n3 >= 128) && (n3 <= 191) &&
(n4 >= 128) && (n4 <= 191) &&
let p = ((n1 land 0b111) lsl 18) lor
((n2 land 0b111111) lsl 12) lor
((n3 land 0b111111) lsl 6) lor
(n4 land 0b111111)
in
(p >= 0x10000) && (p < 0x110000) &&
check s (i+4) j
(n2 lsr 6 == 0b10) && (n3 lsr 6 == 0b10) && (n4 lsr 6 == 0b10)
&& let p = ((n1 land 0x07) lsl 18) lor ((n2 land 0x3f) lsl 12) lor
((n3 land 0x3f) lsl 6) lor (n4 land 0x3f) in
(p >= 0x10000) && (p < 0x110000)
&& check s (i+4) j
| _ -> false
......@@ -78,7 +72,7 @@ struct
((Char.code c land 0b11111) lsl 12) lor
((Char.code s.[i+1] land 0b111111) lsl 6) lor
((Char.code s.[i+2] land 0b111111))
| '\240'..'\248' as c ->
| '\240'..'\247' as c ->
((Char.code c land 0b11111) lsl 18) lor
((Char.code s.[i+1] land 0b111111) lsl 12) lor
((Char.code s.[i+2] land 0b111111) lsl 6) lor
......@@ -96,7 +90,7 @@ struct
((Char.code c land 0b1111) lsl 12) lor
((Char.code s.[i+1] land 0b111111) lsl 6) lor
((Char.code s.[i+2] land 0b111111)), i + 3
| '\240'..'\248' as c ->
| '\240'..'\247' as c ->
((Char.code c land 0b111) lsl 18) lor
((Char.code s.[i+1] land 0b111111) lsl 12) lor
((Char.code s.[i+2] land 0b111111) lsl 6) lor
......@@ -127,7 +121,7 @@ struct
| '\000'..'\127' as c -> i + 1
| '\192'..'\223' as c -> i + 2
| '\224'..'\239' as c -> i + 3
| '\240'..'\248' as c -> i + 4
| '\240'..'\247' as c -> i + 4
| _ -> failwith "Malformed UTF-8 bufffer"
(*
let width = Array.create 256 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment