Fix leading utf8 byte detection
authormalc <av1474@comtv.ru>
Fri, 14 Dec 2012 20:01:37 +0000 (15 00:01 +0400)
committermalc <av1474@comtv.ru>
Fri, 14 Dec 2012 20:01:37 +0000 (15 00:01 +0400)
main.ml

diff --git a/main.ml b/main.ml
index 3f5a039..0011b59 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -3002,9 +3002,9 @@ let withoutlastutf8 s =
       then pos
       else
         let b = Char.code s.[pos] in
-        if b land 0b110000 = 0b11000000
-        then find (pos-1)
-        else pos-1
+        if b land 0b11000000 = 0b11000000
+        then pos
+        else find (pos-1)
     in
     let first =
       if Char.code s.[len-1] land 0x80 = 0