]> gitweb.factorcode.org Git - factor.git/commitdiff
io.encodings.utf8 fixed for bootstrap; add unit tests
authorU-SLAVA-DFB8FF805\Slava <Slava@slava-dfb8ff805.(none)>
Thu, 5 Mar 2009 03:33:34 +0000 (21:33 -0600)
committerU-SLAVA-DFB8FF805\Slava <Slava@slava-dfb8ff805.(none)>
Thu, 5 Mar 2009 03:33:34 +0000 (21:33 -0600)
core/io/encodings/utf8/utf8-tests.factor [changed mode: 0644->0755]
core/io/encodings/utf8/utf8.factor [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index a99575b..e30e9be
@@ -22,3 +22,6 @@ IN: io.encodings.utf8.tests
 
 [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 BIN: 11101111 BIN: 10000000 BIN: 10111111 BIN: 11011111 BIN: 10000000 CHAR: x } ]
 [ { BIN: 101111111000000111111 BIN: 1111000000111111 BIN: 11111000000 CHAR: x } encode-utf8-w/stream ] unit-test
+
+[ 3 ] [ 1 "日本語" >utf8-index ] unit-test
+[ 3 ] [ 9 "日本語" utf8-index> ] unit-test
old mode 100644 (file)
new mode 100755 (executable)
index 69a6abf..aca36c8
@@ -1,8 +1,7 @@
 ! Copyright (C) 2006, 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math math.order kernel sequences sbufs vectors growable io
-continuations namespaces io.encodings combinators strings
-binary-search ;
+continuations namespaces io.encodings combinators strings ;
 IN: io.encodings.utf8
 
 ! Decoding UTF-8
@@ -85,7 +84,7 @@ PRIVATE>
     0 [ code-point-length + ] accumulate swap suffix ;
 
 : utf8-index> ( n string -- n' )
-    code-point-offsets natural-search drop ;
+    code-point-offsets [ <= ] with find drop ;
 
 : >utf8-index ( n string -- n' )
     code-point-offsets nth ;
\ No newline at end of file