]> gitweb.factorcode.org Git - factor.git/commitdiff
putting encodings on all file readers/writers
authorDaniel Ehrenberg <ehrenbed@carleton.edu>
Sun, 17 Feb 2008 04:17:41 +0000 (22:17 -0600)
committerDaniel Ehrenberg <ehrenbed@carleton.edu>
Sun, 17 Feb 2008 04:17:41 +0000 (22:17 -0600)
62 files changed:
core/alien/c-types/c-types.factor
core/bootstrap/image/image.factor
core/io/encodings/binary/binary.factor
core/io/encodings/encodings.factor
core/io/encodings/utf16/utf16.factor
core/io/encodings/utf8/utf8.factor
core/io/files/files-tests.factor
core/io/io-tests.factor
core/io/streams/c/c-tests.factor
core/io/streams/c/c.factor
core/io/streams/lines/lines.factor
core/parser/parser.factor
core/source-files/source-files.factor
extra/benchmark/fasta/fasta.factor
extra/benchmark/knucleotide/knucleotide.factor
extra/benchmark/mandel/mandel.factor
extra/benchmark/raytracer/raytracer.factor
extra/benchmark/reverse-complement/reverse-complement.factor
extra/benchmark/sum-file/sum-file.factor
extra/bootstrap/image/upload/upload.factor
extra/bunny/model/model.factor
extra/cpu/8080/emulator/emulator.factor
extra/cryptlib/cryptlib-tests.factor
extra/crypto/hmac/hmac.factor
extra/crypto/md5/md5.factor
extra/crypto/sha1/sha1.factor
extra/editors/jedit/jedit.factor
extra/furnace/furnace.factor
extra/graphics/bitmap/bitmap.factor
extra/help/cookbook/cookbook.factor
extra/http/client/client.factor
extra/http/server/templating/templating-tests.factor
extra/http/server/templating/templating.factor
extra/icfp/2006/2006.factor
extra/id3/id3.factor
extra/io/mmap/mmap-tests.factor
extra/io/unix/unix-tests.factor
extra/log-viewer/log-viewer.factor
extra/logging/insomniac/insomniac.factor
extra/logging/server/server.factor
extra/mad/api/api.factor
extra/msxml-to-csv/msxml-to-csv.factor
extra/ogg/player/player.factor
extra/porter-stemmer/porter-stemmer-tests.factor
extra/project-euler/042/042.factor
extra/project-euler/067/067.factor
extra/project-euler/079/079.factor
extra/raptor/raptor.factor
extra/rss/rss-tests.factor
extra/tar/tar.factor
extra/tools/browser/browser.factor
extra/tools/deploy/macosx/macosx.factor
extra/tools/disassembler/disassembler.factor
extra/ui/freetype/freetype.factor
extra/unicode/breaks/breaks.factor
extra/unicode/data/data.factor
extra/webapps/file/file.factor
extra/webapps/source/source.factor
extra/xml/xml.factor
extra/xmode/catalog/catalog.factor
extra/xmode/code2html/code2html.factor
extra/yahoo/yahoo-tests.factor

index 7d01fb2b00966b6834e4d2f27a5e7cf660ef3f61..983fea0159d7d8746f265c89ad3ab69fc9692528 100755 (executable)
@@ -4,7 +4,7 @@ USING: bit-arrays byte-arrays float-arrays arrays
 generator.registers assocs kernel kernel.private libc math
 namespaces parser sequences strings words assocs splitting
 math.parser cpu.architecture alien alien.accessors quotations
-system compiler.units ;
+system compiler.units io.encodings.binary ;
 IN: alien.c-types
 
 DEFER: <int>
@@ -273,6 +273,9 @@ M: long-long-type box-return ( type -- )
         r> add*
     ] when ;
 
+: malloc-file-contents ( path -- alien )
+  binary file-contents >byte-array malloc-byte-array ;
+
 [
     [ alien-cell ]
     [ set-alien-cell ]
index 17b56458ce905a9018d476324a07abeb7b06e840..73085450a8af0ddfc1a00b91b0c9c340e06e2c55 100755 (executable)
@@ -7,7 +7,7 @@ strings sbufs vectors words quotations assocs system layouts
 splitting growable classes tuples words.private
 io.binary io.files vocabs vocabs.loader source-files
 definitions debugger float-arrays quotations.private
-sequences.private combinators ;
+sequences.private combinators io.encodings.binary ;
 IN: bootstrap.image
 
 : my-arch ( -- arch )
@@ -416,7 +416,7 @@ M: curry '
     "Writing image to " write
     architecture get boot-image-name resource-path
     dup write "..." print flush
-    [ (write-image) ] with-file-writer ;
+    binary [ (write-image) ] with-file-writer ;
 
 PRIVATE>
 
index 17c734b9c834370223921cb0faa92d0f5777196d..8a8d09464b0dd29eb8b354a2f4280dd3d1563838 100644 (file)
@@ -1,2 +1 @@
-IN: io.encodings.binary
-SYMBOL: binary
+IN: io.encodings.binary SYMBOL: binary
index 4ceae70fae58e9cfc14082dd0829e1981a810504..cd9d4b585b1eb7bacef92c085c51b2716b5e76fb 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2007 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel sequences sbufs vectors namespaces
-growable strings io classes io.streams.c continuations
+growable strings io classes continuations
 io.styles io.streams.nested io.encodings.binary ;
 IN: io.encodings
 
@@ -13,12 +13,12 @@ TUPLE: decode-error ;
 
 SYMBOL: begin
 
-: decoded ( buf ch -- buf ch state )
+: push-decoded ( buf ch -- buf ch state )
     over push 0 begin ;
 
 : push-replacement ( buf -- buf ch state )
     ! This is the replacement character
-    HEX: fffd decoded ;
+    HEX: fffd push-decoded ;
 
 : finish-decoding ( buf ch state -- str )
     begin eq? [ decode-error ] unless drop "" like ;
@@ -59,16 +59,16 @@ TUPLE: decoded code cr ;
         decoded construct
     ] if ;
 
-: cr+ t swap set-line-reader-cr ; inline
+: cr+ t swap set-decoded-cr ; inline
 
-: cr- f swap set-line-reader-cr ; inline
+: cr- f swap set-decoded-cr ; inline
 
 : line-ends/eof ( stream str -- str ) f like swap cr- ; inline
 
 : line-ends\r ( stream str -- str ) swap cr+ ; inline
 
 : line-ends\n ( stream str -- str )
-    over line-reader-cr over empty? and
+    over decoded-cr over empty? and
     [ drop dup cr- stream-readln ] [ swap cr- ] if ; inline
 
 : handle-readln ( stream str ch -- str )
@@ -79,7 +79,7 @@ TUPLE: decoded code cr ;
     } case ;
 
 : fix-read ( stream string -- string )
-    over line-reader-cr [
+    over decoded-cr [
         over cr-
         "\n" ?head [
             swap stream-read1 [ add ] when*
@@ -91,13 +91,21 @@ M: decoded stream-read
 
 M: decoded stream-read-partial tuck stream-read fix-read ;
 
+: read-until-loop ( stream delim -- ch )
+    ! Copied from { c-reader stream-read-until }!!!
+    over stream-read1 dup [
+        dup pick memq? [ 2nip ] [ , read-until-loop ] if
+    ] [
+        2nip
+    ] if ;
+
 M: decoded stream-read-until
     ! Copied from { c-reader stream-read-until }!!!
     [ swap read-until-loop ] "" make
     swap over empty? over not and [ 2drop f f ] when ;
 
 : fix-read1 ( stream char -- char )
-    over line-reader-cr [
+    over decoded-cr [
         over cr-
         dup CHAR: \n = [
             drop stream-read1
@@ -106,7 +114,7 @@ M: decoded stream-read-until
 
 M: decoded stream-read1 1 over stream-read ;
 
-M: line-reader stream-readln ( stream -- str )
+M: decoded stream-readln ( stream -- str )
     "\r\n" over stream-read-until handle-readln ;
 
 ! Encoding
index 35b6282e21b4f50e1762418f2d08d47a3d66aba9..1dd317d3c0f4b24a11e06618dfa3650d240bfcef 100755 (executable)
@@ -16,7 +16,7 @@ SYMBOL: ignore
     8 shift bitor ;
 
 : end-multibyte ( buf byte ch -- buf ch state )
-    append-nums decoded ;
+    append-nums push-decoded ;
 
 : begin-utf16be ( buf byte -- buf ch state )
     dup -3 shift BIN: 11011 number= [
@@ -36,7 +36,7 @@ SYMBOL: ignore
         { double [ end-multibyte ] }
         { quad1 [ append-nums quad2 ] }
         { quad2 [ handle-quad2be ] }
-        { quad3 [ append-nums HEX: 10000 + decoded ] }
+        { quad3 [ append-nums HEX: 10000 + push-decoded ] }
         { ignore [ 2drop push-replacement ] }
     } case ;
 
@@ -52,7 +52,7 @@ SYMBOL: ignore
 
 : handle-quad3le ( buf byte ch -- buf ch state )
     swap dup -2 shift BIN: 110111 = [
-        BIN: 11 bitand append-nums HEX: 10000 + decoded
+        BIN: 11 bitand append-nums HEX: 10000 + push-decoded
     ] [ 2drop push-replacement ] if ;
 
 : decode-utf16le-step ( buf byte ch state -- buf ch state )
index 6a3a8b8ec7abb3ca90926a72eb5b96e4de1c4ef0..7f211f92de1f4de49d6151a78c55cdca30a2cfc6 100644 (file)
@@ -23,7 +23,7 @@ SYMBOL: quad3
 
 : begin-utf8 ( buf byte -- buf ch state )
     {
-        { [ dup -7 shift zero? ] [ decoded ] }
+        { [ dup -7 shift zero? ] [ push-decoded ] }
         { [ dup -5 shift BIN: 110 number= ] [ BIN: 11111 bitand double ] }
         { [ dup -4 shift BIN: 1110 number= ] [ BIN: 1111 bitand triple ] }
         { [ dup -3 shift BIN: 11110 number= ] [ BIN: 111 bitand quad ] }
@@ -31,7 +31,7 @@ SYMBOL: quad3
     } cond ;
 
 : end-multibyte ( buf byte ch -- buf ch state )
-    f append-nums [ decoded ] unless* ;
+    f append-nums [ push-decoded ] unless* ;
 
 : decode-utf8-step ( buf byte ch state -- buf ch state )
     {
index d0f9737f19b13d827a55bf96ec2a1b8834b57d7b..a92a52a024477695decc2d3d32cf4edcc3a28ec1 100755 (executable)
@@ -1,34 +1,34 @@
 IN: temporary
-USING: tools.test io.files io threads kernel continuations ;
+USING: tools.test io.files io threads kernel continuations io.encodings.ascii ;
 
 [ "passwd" ] [ "/etc/passwd" file-name ] unit-test
 [ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test
 [ "awk" ] [ "/usr/libexec/awk///" file-name ] unit-test
 
 [ ] [
-    "test-foo.txt" resource-path [
+    "test-foo.txt" resource-path ascii [
         "Hello world." print
     ] with-file-writer
 ] unit-test
 
 [ ] [
-    "test-foo.txt" resource-path <file-appender> [
+    "test-foo.txt" resource-path ascii [
         "Hello appender." print
-    ] with-stream
+    ] with-file-appender
 ] unit-test
 
 [ ] [
-    "test-bar.txt" resource-path <file-appender> [
+    "test-bar.txt" resource-path ascii [
         "Hello appender." print
-    ] with-stream
+    ] with-file-appender
 ] unit-test
 
 [ "Hello world.\nHello appender.\n" ] [
-    "test-foo.txt" resource-path file-contents
+    "test-foo.txt" resource-path ascii file-contents
 ] unit-test
 
 [ "Hello appender.\n" ] [
-    "test-bar.txt" resource-path file-contents
+    "test-bar.txt" resource-path ascii file-contents
 ] unit-test
 
 [ ] [ "test-foo.txt" resource-path delete-file ] unit-test
@@ -42,7 +42,7 @@ USING: tools.test io.files io threads kernel continuations ;
 [ ] [ "test-blah" resource-path make-directory ] unit-test
 
 [ ] [
-    "test-blah/fooz" resource-path <file-writer> dispose
+    "test-blah/fooz" resource-path ascii <file-writer> dispose
 ] unit-test
 
 [ t ] [
@@ -55,11 +55,11 @@ USING: tools.test io.files io threads kernel continuations ;
 
 [ f ] [ "test-blah" resource-path exists? ] unit-test
 
-[ ] [ "test-quux.txt" resource-path [ [ yield "Hi" write ] in-thread ] with-file-writer ] unit-test
+[ ] [ "test-quux.txt" resource-path ascii [ [ yield "Hi" write ] in-thread ] with-file-writer ] unit-test
 
 [ ] [ "test-quux.txt" resource-path delete-file ] unit-test
 
-[ ] [ "test-quux.txt" resource-path [ [ yield "Hi" write ] in-thread ] with-file-writer ] unit-test
+[ ] [ "test-quux.txt" resource-path ascii [ [ yield "Hi" write ] in-thread ] with-file-writer ] unit-test
 
 [ ] [ "test-quux.txt" "quux-test.txt" [ resource-path ] 2apply rename-file ] unit-test
 [ t ] [ "quux-test.txt" resource-path exists? ] unit-test
index 00a8078da86fde2a4813f4091029629c6dd243e0..74b6b5034f58df549a5543f95e5713f0cf18f6cb 100644 (file)
@@ -1,5 +1,5 @@
 USING: arrays io io.files kernel math parser strings system
-tools.test words namespaces io.encodings.ascii ;
+tools.test words namespaces io.encodings.ascii io.encodings.binary ;
 IN: temporary
 
 [ f ] [
@@ -8,7 +8,7 @@ IN: temporary
 ] unit-test
 
 : <resource-reader> ( resource -- stream )
-    resource-path binary ascii <file-reader> ;
+    resource-path ascii <file-reader> ;
 
 [
     "This is a line.\rThis is another line.\r"
@@ -53,7 +53,7 @@ IN: temporary
 ] unit-test
 
 [ ] [
-    image [
+    image binary [
         10 [ 65536 read drop ] times
     ] with-file-reader
 ] unit-test
index 5ace929ceba43b85a51a5044d2f19a5a22bb1591..66ea46012607745676d70a553e4c5d88f7f475fd 100755 (executable)
@@ -2,7 +2,7 @@ USING: tools.test io.files io io.streams.c ;
 IN: temporary
 
 [ "hello world" ] [
-    "test.txt" resource-path [
+    "test.txt" resource-path ascii [
         "hello world" write
     ] with-file-writer
 
index 9c1a099318fd4976545d57f55ca05f65140324ff..73b8bb32b9f03d23b4326612883c74f4c62b0b60 100755 (executable)
@@ -2,8 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel kernel.private namespaces io
 strings sequences math generic threads.private classes
-io.backend io.streams.lines io.streams.plain io.streams.duplex
-io.files continuations ;
+io.backend io.streams.duplex io.files continuations ;
 IN: io.streams.c
 
 TUPLE: c-writer handle ;
index a6a5721ad855a76c9442b720e4be520019898b50..84ff272d69fa4a95533f9a405fb187a361b9efe1 100755 (executable)
@@ -1,9 +1,7 @@
 ! Copyright (C) 2004, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 IN: io.streams.lines
-USING: io.encodings.latin1 io.encodings ;
+USING: io.encodings.latin1 io.encodings ;
 
-TUPLE: line-reader cr ;
-
-: <line-reader> ( stream -- new-stream )
-    latin1 <decoded> ;
+! : <line-reader> ( stream -- new-stream )
+!     latin1 <decoded> ;
index fc29445f88fc39434bd3cc351df10fb02fc7c21b..2f7beb56d784548e9d30b7165bb9c65c202d4166 100755 (executable)
@@ -4,7 +4,7 @@ USING: arrays definitions generic assocs kernel math
 namespaces prettyprint sequences strings vectors words
 quotations inspector io.styles io combinators sorting
 splitting math.parser effects continuations debugger 
-io.files io.streams.string io.streams.lines vocabs
+io.files io.streams.string io.streams.lines vocabs io.encodings.utf8
 source-files classes hashtables compiler.errors compiler.units ;
 IN: parser
 
@@ -489,7 +489,7 @@ SYMBOL: interactive-vocabs
     [
         [
             [ parsing-file ] keep
-            [ ?resource-path <file-reader> ] keep
+            [ ?resource-path utf8 <file-reader> ] keep
             parse-stream
         ] with-compiler-errors
     ] [
index c7539ad3eb83e7034801552ec91d83e18cfc8880..d2566982f8061ca439a5327dbe8f568c118b0b5b 100755 (executable)
@@ -5,7 +5,7 @@ namespaces prettyprint sequences strings vectors words
 quotations inspector io.styles io combinators sorting
 splitting math.parser effects continuations debugger
 io.files io.crc32 io.streams.string io.streams.lines vocabs
-hashtables graphs compiler.units ;
+hashtables graphs compiler.units io.encodings.utf8 ;
 IN: source-files
 
 SYMBOL: source-files
@@ -17,7 +17,7 @@ uses definitions ;
 
 : (source-modified?) ( path modified checksum -- ? )
     pick file-modified rot [ 0 or ] 2apply >
-    [ swap file-lines lines-crc32 = not ] [ 2drop f ] if ;
+    [ swap utf8 file-lines lines-crc32 = not ] [ 2drop f ] if ;
 
 : source-modified? ( path -- ? )
     dup source-files get at [
@@ -68,7 +68,7 @@ uses definitions ;
 : reset-checksums ( -- )
     source-files get [
         swap ?resource-path dup exists?
-        [ file-lines swap record-checksum ] [ 2drop ] if
+        [ utf8 file-lines swap record-checksum ] [ 2drop ] if
     ] assoc-each ;
 
 M: pathname where pathname-string 1 2array ;
index 75321def2d69a8ad4e6ce7f7ab89e5c039b42c2d..a68a84fc59d4dd6566ed994fac695746b8ccf393 100644 (file)
@@ -1,6 +1,6 @@
 ! Based on http://shootout.alioth.debian.org/gp4/benchmark.php?test=fasta&lang=java&id=2
 USING: math kernel io io.files locals multiline assocs sequences
-sequences.private benchmark.reverse-complement hints
+sequences.private benchmark.reverse-complement hints io.encodings.ascii
 byte-arrays float-arrays ;
 IN: benchmark.fasta
 
@@ -94,7 +94,7 @@ HINTS: random fixnum ;
            n [ ]
            seed [ initial-seed ] |
 
-        out [
+        out ascii [
             n 2 * ALU "Homo sapiens alu" "ONE" write-repeat-fasta
 
             initial-seed
index b95e182bd1dd97a13da7865277e2ae87395396be..e06b81f6deb7e49eb6195e9ae45db45b6f93d266 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel io io.files splitting strings
+USING: kernel io io.files splitting strings io.encodings.ascii
        hashtables sequences assocs math namespaces prettyprint
        math.parser combinators arrays sorting unicode.case ;
 
@@ -57,7 +57,7 @@ IN: benchmark.knucleotide
 
 : knucleotide ( -- )
     "extra/benchmark/knucleotide/knucleotide-input.txt" resource-path
-    [ read-input ] with-file-reader
+    ascii [ read-input ] with-file-reader
     process-input ;
 
 MAIN: knucleotide
index 230fb2f889f930387af782961551962739516138..a60fdbf6c7f672f87cb1bd4e352e1557acd526bb 100755 (executable)
@@ -1,6 +1,6 @@
 IN: benchmark.mandel
 USING: arrays io kernel math namespaces sequences strings sbufs
-math.functions math.parser io.files colors.hsv ;
+math.functions math.parser io.files colors.hsv io.encodings.binary ;
 
 : max-color 360 ; inline
 : zoom-fact 0.8 ; inline
@@ -66,6 +66,6 @@ SYMBOL: cols
 
 : mandel-main ( -- )
     "mandel.ppm" resource-path
-    [ mandel write ] with-file-writer ;
+    binary [ mandel write ] with-file-writer ;
 
 MAIN: mandel-main
index 8f2badc95f064777e35a55e47a15732a15a0a018..9783389e80dfe38c97401bb6a11a077210296a89 100644 (file)
@@ -3,7 +3,7 @@
 
 USING: float-arrays compiler generic io io.files kernel math
 math.functions math.vectors math.parser namespaces sequences
-sequences.private words ;
+sequences.private words io.encodings.binary ;
 IN: benchmark.raytracer
 
 ! parameters
@@ -171,6 +171,6 @@ DEFER: create ( level c r -- scene )
 
 : raytracer-main
     "raytracer.pnm" resource-path
-    [ run write ] with-file-writer ;
+    binary [ run write ] with-file-writer ;
 
 MAIN: raytracer-main
index cc20b4b3493407dc47b1939f4cc7ab12d98738ff..2ae92223d1873c4726f1468822ba950d79215919 100644 (file)
@@ -1,6 +1,6 @@
 USING: io io.files io.streams.duplex kernel sequences
 sequences.private strings vectors words memoize splitting
-hints unicode.case ;
+hints unicode.case io.encodings.latin1 ;
 IN: benchmark.reverse-complement
 
 MEMO: trans-map ( -- str )
@@ -32,7 +32,7 @@ HINTS: do-line vector string ;
     readln [ do-line (reverse-complement) ] [ show-seq ] if* ;
 
 : reverse-complement ( infile outfile -- )
-    <file-writer> >r <file-reader> r> <duplex-stream> [
+    latin1 <file-writer> >r latin1 <file-reader> r> <duplex-stream> [
         500000 <vector> (reverse-complement)
     ] with-stream ;
 
index e17765d5425c27ab48bcbcf49b760ff4b31ce19c..3db31f8887d5ae73932ab30ef4be5adc7aae3bc1 100644 (file)
@@ -1,11 +1,11 @@
-USING: io io.files math math.parser kernel prettyprint ;
+USING: io io.files math math.parser kernel prettyprint io.encodings.ascii ;
 IN: benchmark.sum-file
 
 : sum-file-loop ( n -- n' )
     readln [ string>number + sum-file-loop ] when* ;
 
 : sum-file ( file -- )
-    [ 0 sum-file-loop ] with-file-reader . ;
+    ascii [ 0 sum-file-loop ] with-file-reader . ;
 
 : sum-file-main ( -- )
     home "sum-file-in.txt" path+ sum-file ;
index 552e26ebf557f2cdbd76e796dbb1ed453fb5f091..4b8ddb0c4b5838b308171de0790761f599fcbb49 100755 (executable)
@@ -2,14 +2,14 @@
 ! See http://factorcode.org/license.txt for BSD license.
 IN: bootstrap.image.upload
 USING: http.client crypto.md5 splitting assocs kernel io.files
-bootstrap.image sequences io namespaces io.launcher math ;
+bootstrap.image sequences io namespaces io.launcher math io.encodings.ascii ;
 
 : destination "slava@factorcode.org:www/images/latest/" ;
 
 : boot-image-names images [ boot-image-name ] map ;
 
 : compute-checksums ( -- )
-    "checksums.txt" [
+    "checksums.txt" ascii [
         boot-image-names [ dup write bl file>md5str print ] each
     ] with-file-writer ;
 
index 7c77ed98af92283c95a3bf96d70b16c6943d9fc1..8d2175846ce55c445b874f904694d175bfd383c0 100644 (file)
@@ -1,5 +1,5 @@
 USING: alien alien.c-types arrays sequences math math.vectors math.matrices
-    math.parser io io.files kernel opengl opengl.gl opengl.glu
+    math.parser io io.files kernel opengl opengl.gl opengl.glu io.encodings.ascii
     opengl.capabilities shuffle http.client vectors splitting tools.time system
     combinators combinators.cleave float-arrays continuations namespaces
     sequences.lib ;
@@ -35,7 +35,7 @@ IN: bunny.model
 
 : read-model ( stream -- model )
     "Reading model" print flush [
-        [ parse-model ] with-file-reader
+        ascii [ parse-model ] with-file-reader
         [ normals ] 2keep 3array
     ] time ;
 
index 9499ff8dff733ea5258dc7f0623ac4bf1f0c462f..9189a414111f422d3eb6a435205da3d03258bde5 100755 (executable)
@@ -4,7 +4,7 @@
 USING: kernel math sequences words arrays io 
        io.files namespaces math.parser kernel.private
        assocs quotations parser parser-combinators tools.time
-       sequences.private compiler.units ;
+       sequences.private compiler.units io.encodings.binary ;
 IN: cpu.8080.emulator
 
 TUPLE: cpu b c d e f h l a pc sp halted? last-interrupt cycles ram ;
@@ -461,7 +461,7 @@ M: cpu reset ( cpu -- )
 : load-rom ( filename cpu -- )
   #! Load the contents of the file into ROM.
   #! (address 0x0000-0x1FFF).
-  cpu-ram swap [ 
+  cpu-ram swap binary 
     0 swap (load-rom)
   ] with-file-reader ;
 
@@ -477,7 +477,7 @@ SYMBOL: rom-root
   #! file path shoul dbe relative to the '/roms' resource path.
   rom-dir [
     cpu-ram [
-      swap first2 rom-dir swap path+ [      
+      swap first2 rom-dir swap path+ binary [      
         swap (load-rom)
       ] with-file-reader
     ] curry each 
index c40411471647b4cdfa2472c215d7e5678726cad0..aeac468ba307e0f832816714a19747f1e36d9eb2 100644 (file)
@@ -1,5 +1,6 @@
 USING: cryptlib.libcl cryptlib prettyprint kernel alien sequences libc math
-tools.test io io.files continuations alien.c-types splitting generic.math ;
+tools.test io io.files continuations alien.c-types splitting generic.math
+io.encodings.binary ;
 
 "=========================================================" print
 "Envelope/de-envelop test..." print
@@ -152,7 +153,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
     ! envelope
     CRYPT_FORMAT_CRYPTLIB [
         "extra/cryptlib/test/large_data.txt" resource-path
-        file-contents set-pop-buffer
+        binary file-contents set-pop-buffer
         envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE
         get-pop-buffer alien>char-string length 10000 + set-attribute
         envelope-handle CRYPT_ENVINFO_DATASIZE
@@ -192,7 +193,7 @@ tools.test io io.files continuations alien.c-types splitting generic.math ;
     CRYPT_FORMAT_CRYPTLIB [
         envelope-handle CRYPT_ENVINFO_PASSWORD "password" set-attribute-string
         "extra/cryptlib/test/large_data.txt" resource-path
-        file-contents set-pop-buffer
+        binary file-contents set-pop-buffer
         envelope-handle CRYPT_ATTRIBUTE_BUFFERSIZE
         get-pop-buffer alien>char-string length 10000 + set-attribute
         envelope-handle CRYPT_ENVINFO_DATASIZE
index 7c358a8c0971d3e21a456a5e69b4908b80218bf8..56d39e71dc7fa5695fb7aeaff8fe766d4d7d9a97 100644 (file)
@@ -1,6 +1,6 @@
 USING: arrays combinators crypto.common crypto.md5 crypto.sha1
 crypto.md5.private io io.binary io.files io.streams.string
-kernel math math.vectors memoize sequences ;
+kernel math math.vectors memoize sequences io.encodings.binary ;
 IN: crypto.hmac
 
 : sha1-hmac ( Ko Ki -- hmac )
@@ -32,7 +32,7 @@ MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
     [ init-hmac sha1-hmac ] with-stream ;
 
 : file>sha1-hmac ( K path -- hmac )
-    <file-reader> stream>sha1-hmac ;
+    binary <file-reader> stream>sha1-hmac ;
 
 : string>sha1-hmac ( K string -- hmac )
     <string-reader> stream>sha1-hmac ;
@@ -42,7 +42,7 @@ MEMO: opad ( -- seq ) 64 HEX: 5c <array> ;
     [ init-hmac md5-hmac ] with-stream ;
 
 : file>md5-hmac ( K path -- hmac )
-    <file-reader> stream>md5-hmac ;
+    binary <file-reader> stream>md5-hmac ;
 
 : string>md5-hmac ( K string -- hmac )
     <string-reader> stream>md5-hmac ;
index fe215e32db568d02b3f959c452013c38205d8ae7..9ca3561574a7f1f0414d8c530d0ec8138de47084 100644 (file)
@@ -2,7 +2,8 @@
 
 USING: kernel io io.binary io.files io.streams.string math
 math.functions math.parser namespaces splitting strings
-sequences crypto.common byte-arrays locals sequences.private ;
+sequences crypto.common byte-arrays locals sequences.private
+io.encodings.binary ;
 IN: crypto.md5
 
 <PRIVATE
@@ -186,5 +187,5 @@ PRIVATE>
 
 : string>md5 ( string -- byte-array ) <string-reader> stream>md5 ;
 : string>md5str ( string -- md5-string ) string>md5 hex-string ;
-: file>md5 ( path -- byte-array ) <file-reader> stream>md5 ;
+: file>md5 ( path -- byte-array ) binary <file-reader> stream>md5 ;
 : file>md5str ( path -- md5-string ) file>md5 hex-string ;
index f6dfbcd031f875b3887ec9706b0d12435b78895a..8f8b3e0cddca707ad36d9bc11c8d94970926eb58 100644 (file)
@@ -1,4 +1,4 @@
-USING: arrays combinators crypto.common kernel io io.binary
+USING: arrays combinators crypto.common kernel io io.encodings.binary
 io.files io.streams.string math.vectors strings sequences
 namespaces math parser sequences vectors
 hashtables ;
@@ -123,7 +123,7 @@ SYMBOL: K
 : string>sha1 ( string -- sha1 ) <string-reader> stream>sha1 ;
 : string>sha1str ( string -- str ) string>sha1 hex-string ;
 : string>sha1-bignum ( string -- n ) string>sha1 be> ;
-: file>sha1 ( file -- sha1 ) <file-reader> stream>sha1 ;
+: file>sha1 ( file -- sha1 ) binary <file-reader> stream>sha1 ;
 
 : string>sha1-interleave ( string -- seq )
     [ zero? ] left-trim
index fd5b6c1b068854ded0d81d4064b43b2353471a12..ed579dde42b838e3d704f2e9bd70345ca939a589 100644 (file)
@@ -3,11 +3,11 @@
 USING: arrays definitions io kernel math
 namespaces parser prettyprint sequences strings words
 editors io.files io.sockets io.streams.string io.binary
-math.parser ;
+math.parser io.encodings.ascii ;
 IN: editors.jedit
 
 : jedit-server-info ( -- port auth )
-    home "/.jedit/server" path+ [
+    home "/.jedit/server" path+ ascii [
         readln drop
         readln string>number
         readln string>number
index 9b7a8a8aa5dc3898ecf99551b56d33dbed96b8f8..b8e8b6885f64abc55e4807a605590b7f0229b222 100755 (executable)
@@ -5,7 +5,7 @@ furnace.validator hashtables heaps html.elements http
 http.server.responders http.server.templating io.files kernel
 math namespaces quotations sequences splitting words strings
 vectors webapps.callback continuations tuples classes vocabs
-html io ;
+html io io.encodings.binary ;
 IN: furnace
 
 : code>quotation ( word/quot -- quot )
@@ -194,7 +194,7 @@ SYMBOL: model
     </a> ;
 
 : send-resource ( name -- )
-    template-path get swap path+ resource-path <file-reader>
+    template-path get swap path+ resource-path binary <file-reader>
     stdio get stream-copy ;
 
 : render-link ( quot name -- )
index 8e61766de18b04d28401119502a11fa7ace00866..ec4d6b79e1ea86e4d471694177c9149446eb489a 100644 (file)
@@ -4,7 +4,7 @@
 USING: alien arrays byte-arrays combinators
 graphics.viewer io io.binary io.files kernel libc math
 math.functions namespaces opengl opengl.gl prettyprint
-sequences strings ui ui.gadgets.panes ;
+sequences strings ui ui.gadgets.panes io.encodings.binary ;
 IN: graphics.bitmap
 
 ! Currently can only handle 24bit bitmaps.
@@ -59,7 +59,7 @@ TUPLE: bitmap magic size reserved offset header-length width
     dup color-index-length read swap set-bitmap-color-index ;
 
 : load-bitmap ( path -- bitmap )
-    [
+    binary [
         T{ bitmap } clone
         dup parse-file-header
         dup parse-bitmap-header
@@ -69,7 +69,7 @@ TUPLE: bitmap magic size reserved offset header-length width
     raw-bitmap>string >byte-array over set-bitmap-array ;
 
 : save-bitmap ( bitmap path -- )
-    [
+    binary [
         "BM" write
         dup bitmap-array length 14 + 40 + 4 >le write
         0 4 >le write
index 5be69663f8123c0ba2dd0e7c71666f5cd3deee91..0b22ea2d1e87691df8a6dcae0d6c748811ca32bc 100755 (executable)
@@ -191,11 +191,11 @@ ARTICLE: "cookbook-io" "Input and output cookbook"
 }
 "Print the lines of a file in sorted order:"
 { $code
-    "\"lines.txt\" file-lines natural-sort [ print ] each"
+    "utf8 \"lines.txt\" file-lines natural-sort [ print ] each"
 }
 "Read 1024 bytes from a file:"
 { $code
-    "\"data.bin\" [ 1024 read ] with-file-reader"
+    "\"data.bin\" binary [ 1024 read ] with-file-reader"
 }
 "Convert a file of 4-byte cells from little to big endian or vice versa, by directly mapping it into memory:"
 { $code
index 679d603708d198a2ef5a4413cbd65ee06fa84c78..251015a30d8c90655e5ae149d3457c9ba8693d81 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs http kernel math math.parser namespaces sequences
 io io.sockets io.streams.string io.files io.timeouts strings
-splitting continuations assocs.lib ;
+splitting continuations assocs.lib io.encodings.binary ;
 IN: http.client
 
 : parse-host ( url -- host port )
@@ -71,7 +71,7 @@ DEFER: http-get-stream
 : download-to ( url file -- )
     #! Downloads the contents of a URL to a file.
     >r http-get-stream check-response
-    r> <file-writer> stream-copy ;
+    r> binary <file-writer> stream-copy ;
 
 : download ( url -- )
     dup download-name download-to ;
index d889cd848a6c4c980cf8737a8efba40db6b309be..2c15120552012327f5bf8a54cd3f7de83a17848a 100644 (file)
@@ -1,5 +1,5 @@
 USING: io io.files io.streams.string http.server.templating kernel tools.test
-    sequences ;
+    sequences io.encodings.utf8 ;
 IN: temporary
 
 : test-template ( path -- ? )
@@ -8,7 +8,7 @@ IN: temporary
         ".fhtml" append resource-path
         [ run-template-file ] with-string-writer
     ] keep
-    ".html" append resource-path file-contents = ;
+    ".html" append resource-path utf8 file-contents = ;
 
 [ t ] [ "example" test-template ] unit-test
 [ t ] [ "bug" test-template ] unit-test
index f364b86524643eb574a0e7b1a6460402913f2071..d15bec4fb27bfdc14427452a69ce6b59a7084b8e 100755 (executable)
@@ -4,7 +4,7 @@
 USING: continuations sequences kernel parser namespaces io
 io.files io.streams.lines io.streams.string html html.elements
 source-files debugger combinators math quotations generic
-strings splitting ;
+strings splitting io.encodings.utf8 ;
 
 IN: http.server.templating
 
@@ -82,7 +82,7 @@ DEFER: <% delimiter
             templating-vocab use+
             dup source-file file set ! so that reload works properly
             [
-                ?resource-path file-contents
+                ?resource-path utf8 file-contents
                 [ eval-template ] [ html-error. drop ] recover
             ] keep
         ] with-file-vocabs
@@ -93,4 +93,4 @@ DEFER: <% delimiter
     swap path+ run-template-file ;
 
 : template-convert ( infile outfile -- )
-    [ run-template-file ] with-file-writer ;
+    utf8 [ run-template-file ] with-file-writer ;
index ae0e058490155eb823ed3de824ac06a153ecf034..1740e8a52333f0a0fcae77eb68309d5fe5097084 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math sequences kernel.private namespaces arrays io
 io.files splitting io.binary math.functions vectors quotations
-combinators ;
+combinators io.encodings.binary ;
 IN: icfp.2006
 
 SYMBOL: regs
@@ -134,7 +134,7 @@ SYMBOL: open-arrays
     [ run-op exec-loop ] unless ;
 
 : load-platters ( path -- )
-    file-contents 4 group [ be> ] map
+    binary file-contents 4 group [ be> ] map
     0 arrays get set-nth ;
 
 : init ( path -- )
index 4f633f5be17862a89873a871bc1e4a9f6c3a19cc..02e951545109a57a8331447f3459f99311cfe7fc 100644 (file)
@@ -3,7 +3,7 @@
 
 USING: arrays combinators io io.binary io.files io.paths
 io.encodings.utf16 kernel math math.parser namespaces sequences
-splitting strings assocs unicode.categories ;
+splitting strings assocs unicode.categories io.encodings.binary ;
 
 IN: id3
 
@@ -107,20 +107,20 @@ C: <extended-header> extended-header
   read-header read-frames <tag> ;
 
 : supported-version? ( version -- ? )
-  [ 3 4 ] member? ;
+    { 3 4 } member? ;
 
 : read-id3v2 ( -- tag/f )
   read1 dup supported-version?
   [ (read-id3v2) ] [ drop f ] if ;
 
 : id3v2? ( -- ? )
-  3 read "ID3" = ;
+  3 read "ID3" sequence= ;
 
 : read-tag ( stream -- tag/f )
   id3v2? [ read-id3v2 ] [ f ] if ;
 
 : id3v2 ( filename -- tag/f )
-  [ read-tag ] with-file-reader ;
+  binary [ read-tag ] with-file-reader ;
 
 : file? ( path -- ? )
   stat 3drop not ;
@@ -135,7 +135,7 @@ C: <extended-header> extended-header
   [ mp3? ] subset ;
 
 : id3? ( file -- ? )
-  [ id3v2? ] with-file-reader ;
+  binary [ id3v2? ] with-file-reader ;
 
 : id3s ( files -- id3s )
   [ id3? ] subset ;
index 25caae036d237f2cf5c41e67241e88293297cf55..388deac0db794bb59ca7791b6fab6858beb6e81a 100644 (file)
@@ -1,9 +1,10 @@
-USING: io io.mmap io.files kernel tools.test continuations sequences ;
+USING: io io.mmap io.files kernel tools.test continuations
+sequences io.encodings.ascii ;
 IN: temporary
 
 [ "mmap-test-file.txt" resource-path delete-file ] ignore-errors
-[ ] [ "mmap-test-file.txt" resource-path [ "12345" write ] with-file-writer ] unit-test
+[ ] [ "mmap-test-file.txt" resource-path ascii [ "12345" write ] with-file-writer ] unit-test
 [ ] [ "mmap-test-file.txt" resource-path dup file-length [ CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
 [ 5 ] [ "mmap-test-file.txt" resource-path dup file-length [ length ] with-mapped-file ] unit-test
-[ "22345" ] [ "mmap-test-file.txt" resource-path file-contents ] unit-test
+[ "22345" ] [ "mmap-test-file.txt" resource-path ascii file-contents ] unit-test
 [ "mmap-test-file.txt" resource-path delete-file ] ignore-errors
index e1c3108952d347740b81710249adfd99ca32f6ba..85d450dac99bc03caba8cc001b732a46bf0b8286 100755 (executable)
@@ -1,6 +1,6 @@
 USING: io.files io.sockets io kernel threads namespaces
 tools.test continuations strings byte-arrays sequences
-prettyprint system ;
+prettyprint system io.encodings.binary ;
 IN: temporary
 
 ! Unix domain stream sockets
@@ -131,15 +131,15 @@ client-addr <datagram>
 ! Invalid parameter tests
 
 [
-    image [ stdio get accept ] with-file-reader
+    image binary [ stdio get accept ] with-file-reader
 ] must-fail
 
 [
-    image [ stdio get receive ] with-file-reader
+    image binary [ stdio get receive ] with-file-reader
 ] must-fail
 
 [
-    image [
+    image binary [
         B{ 1 2 } server-addr
         stdio get send
     ] with-file-reader
index 0f139d184ea4bd7c7e3fab0efb8ac9191519ff2c..7bc63d3e3482cb5f4572e41351fbf86e5bf8dc72 100755 (executable)
@@ -1,4 +1,4 @@
-USING: kernel io io.files io.monitors ;\r
+USING: kernel io io.files io.monitors io.encodings.utf8 ;\r
 IN: log-viewer\r
 \r
 : read-lines ( stream -- )\r
@@ -9,6 +9,6 @@ IN: log-viewer
     dup next-change 2drop over read-lines tail-file-loop ;\r
 \r
 : tail-file ( file -- )\r
-    dup <file-reader> dup read-lines\r
+    dup utf8 <file-reader> dup read-lines\r
     swap parent-directory f <monitor>\r
     tail-file-loop ;\r
index bb143879bfc4046148bbdc37b0be8e3852b57952..0294085eda4fcb793d351c3c6c35408bd9a67779 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: logging.analysis logging.server logging smtp io.sockets\r
-kernel io.files io.streams.string namespaces raptor.cron assocs ;\r
+kernel io.files io.streams.string namespaces raptor.cron assocs\r
+io.encodings.utf8 ;\r
 IN: logging.insomniac\r
 \r
 SYMBOL: insomniac-smtp-host\r
@@ -11,7 +12,7 @@ SYMBOL: insomniac-recipients
 \r
 : ?analyze-log ( service word-names -- string/f )\r
     >r log-path 1 log# dup exists? [\r
-        file-lines r> [ analyze-log ] with-string-writer\r
+        utf8 file-lines r> [ analyze-log ] with-string-writer\r
     ] [\r
         r> 2drop f\r
     ] if ;\r
index 05029df1d0c1f8dc32a08179084327a8174df506..e2a57fbc5444d0b70d245a9bdaa80b051a78c66e 100755 (executable)
@@ -3,7 +3,7 @@
 USING: namespaces kernel io calendar sequences io.files\r
 io.sockets continuations prettyprint assocs math.parser\r
 words debugger math combinators concurrency arrays init\r
-math.ranges strings ;\r
+math.ranges strings io.encodings.utf8 ;\r
 IN: logging.server\r
 \r
 : log-root ( -- string )\r
@@ -20,7 +20,7 @@ SYMBOL: log-files
 : open-log-stream ( service -- stream )\r
     log-path\r
     dup make-directories\r
-    1 log# <file-appender> ;\r
+    1 log# utf8 <file-appender> ;\r
 \r
 : log-stream ( service -- stream )\r
     log-files get [ open-log-stream ] cache ;\r
index d803fa64e04ee1ac7cf8dcac8a923e7227069e9f..fdc2903d462ab5c6da33db41e21dc859b1dc1cd7 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007 Adam Wendt.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: alien alien.c-types byte-arrays io io.binary io.files kernel mad\r
-    namespaces prettyprint sbufs sequences tools.interpreter vars ;\r
+    namespaces prettyprint sbufs sequences tools.interpreter vars\r
+    io.encodings.binary ;\r
 IN: mad.api\r
 \r
 VARS: buffer-start buffer-length output-callback-var ;\r
@@ -80,9 +81,6 @@ VARS: buffer-start buffer-length output-callback-var ;
 : make-decoder ( -- decoder )\r
   "mad_decoder" malloc-object ;\r
 \r
-: malloc-file-contents ( path -- alien )\r
-  file-contents >byte-array malloc-byte-array ;\r
-\r
 : mad-run ( -- int )\r
   make-decoder [ mad-init ] keep MAD_DECODER_MODE_SYNC mad_decoder_run ;\r
 \r
index 8a9ba9cf98987107683c927e4538cadb0644be19..3004324511eaa48bf76feb59d0ebbb74257689ba 100644 (file)
@@ -1,4 +1,4 @@
-USING: io io.files sequences xml xml.utilities ;
+USING: io io.files sequences xml xml.utilities io.encodings.utf8 ;
 IN: msxml-to-csv
 
 : print-csv ( table -- ) [ "," join print ] each ;
@@ -13,6 +13,6 @@ IN: msxml-to-csv
     ] map ;
 
 : msxml>csv ( infile outfile -- )
-    [
+    utf8 [
         file>xml (msxml>csv) print-csv
     ] with-file-writer ;
index 518030ee4d12db4a13d19a2afb4488d65f375dd0..94a45c90e3615d762b2e0a1357b3214ae0423604 100644 (file)
@@ -14,7 +14,8 @@ USING: kernel alien ogg ogg.vorbis ogg.theora io byte-arrays
        sequences libc shuffle alien.c-types system openal math\r
        namespaces threads shuffle opengl arrays ui.gadgets.worlds\r
        combinators math.parser ui.gadgets ui.render opengl.gl ui\r
-       continuations io.files hints combinators.lib sequences.lib ;\r
+       continuations io.files hints combinators.lib sequences.lib\r
+       io.encodings.binary ;\r
 \r
 IN: ogg.player\r
 \r
@@ -612,7 +613,7 @@ M: theora-gadget draw-gadget* ( gadget -- )
     <player> play-ogg ;\r
 \r
 : play-vorbis-file ( filename -- )\r
-    <file-reader> play-vorbis-stream ;\r
+    binary <file-reader> play-vorbis-stream ;\r
 \r
 : play-theora-stream ( stream -- )\r
     <player>\r
@@ -620,5 +621,5 @@ M: theora-gadget draw-gadget* ( gadget -- )
     play-ogg ;\r
 \r
 : play-theora-file ( filename -- )\r
-    <file-reader> play-theora-stream ;\r
+    binary <file-reader> play-theora-stream ;\r
 \r
index d3e031fdc690e971b49cfc55eb8b62ebafc61c1d..1e46fcd871180b698d59a7d6244fed5702b3eabc 100644 (file)
@@ -1,6 +1,6 @@
 IN: temporary
 USING: arrays io kernel porter-stemmer sequences tools.test
-io.files ;
+io.files io.encodings.utf8 ;
 
 [ 0 ] [ "xa" consonant-seq ] unit-test
 [ 0 ] [ "xxaa" consonant-seq ] unit-test
@@ -56,7 +56,7 @@ io.files ;
 [ "hell" ] [ "hell" step5 "" like ] unit-test
 [ "mate" ] [ "mate" step5 "" like ] unit-test
 
-: resource-lines resource-path file-lines ;
+: resource-lines resource-path utf8 file-lines ;
 
 [ { } ] [
     "extra/porter-stemmer/test/voc.txt" resource-lines
index c66be27df7b6cdcaae1a63adb52365558ecc4585..a87722debce0da6c82688f08a3cdeb6916285f76 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: ascii io.files kernel math math.functions namespaces
-    project-euler.common sequences sequences.lib splitting ;
+    project-euler.common sequences sequences.lib splitting io.encodings.ascii ;
 IN: project-euler.042
 
 ! http://projecteuler.net/index.php?section=problems&id=42
@@ -31,7 +31,7 @@ IN: project-euler.042
 
 : source-042 ( -- seq )
     "extra/project-euler/042/words.txt" resource-path
-    file-contents [ quotable? ] subset "," split ;
+    ascii file-contents [ quotable? ] subset "," split ;
 
 : (triangle-upto) ( limit n -- )
     2dup nth-triangle > [
index f206f59472ad1fe76994622ee0a4c8e227c2315a..436ccde77609ba8fc9e50d85a3f2005c99c36a2e 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (c) 2007 Samuel Tardieu, Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io.files math.parser namespaces project-euler.common sequences splitting ;
+USING: io.files math.parser namespaces project-euler.common
+io.encodings.ascii sequences splitting ;
 IN: project-euler.067
 
 ! http://projecteuler.net/index.php?section=problems&id=67
@@ -38,7 +39,7 @@ IN: project-euler.067
 
 : source-067 ( -- seq )
     "extra/project-euler/067/triangle.txt" resource-path
-    file-lines [ " " split [ string>number ] map ] map ;
+    ascii file-lines [ " " split [ string>number ] map ] map ;
 
 PRIVATE>
 
index f068db77ec2a41bf5e2018884a917b4db065b2b2..30c46de0a06d6bfc778d5b7c2c2ce3e7de7e79fe 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs hashtables io.files kernel math math.parser namespaces sequences ;
+USING: assocs hashtables io.files kernel math math.parser namespaces
+io.encodings.ascii sequences ;
 IN: project-euler.079
 
 ! http://projecteuler.net/index.php?section=problems&id=79
@@ -26,7 +27,7 @@ IN: project-euler.079
 <PRIVATE
 
 : source-079 ( -- seq )
-    "extra/project-euler/079/keylog.txt" resource-path file-lines ;
+    "extra/project-euler/079/keylog.txt" resource-path ascii file-lines ;
 
 : >edges ( seq -- seq )
     [
index d776739d89a1ff82f2f1cf94e775fdd4bb977412..36da6d9434939a9400aa9cd55b5d519ebfc9278e 100644 (file)
@@ -42,10 +42,10 @@ SYMBOL: networking-hook
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 USING: io io.files io.streams.lines io.streams.plain io.streams.duplex
-       listener ;
+       listener io.encodings.utf8 ;
 
 : tty-listener ( tty -- )
-  [ <file-reader> ] [ <file-writer> ] bi <duplex-stream>
+  [ utf8 <file-reader> ] [ utf8 <file-writer> ] bi <duplex-stream>
   [ listener ] with-stream ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
index 68a40704b3d808be63c2b9a76c47a05741c54563..1d493d3c14f9f40252967d557eb89617115a1ab1 100644 (file)
@@ -1,9 +1,9 @@
-USING: rss io kernel io.files tools.test ;
+USING: rss io kernel io.files tools.test io.encodings.utf8 ;
 
 : load-news-file ( filename -- feed )
     #! Load an news syndication file and process it, returning
     #! it as an feed tuple.
-    <file-reader> read-feed ;
+    utf8 <file-reader> read-feed ;
 
 [ T{
     feed
index d92b4bd48b6d3f66930f9d8712f3a3349f7c364e..ed083386ed6b68d0280f19ccf29c524b3a242b9b 100755 (executable)
@@ -1,7 +1,7 @@
 USING: combinators io io.files io.streams.duplex
 io.streams.string kernel math math.parser continuations
 namespaces pack prettyprint sequences strings system
-hexdump tools.interpreter ;
+hexdump tools.interpreter io.encodings.binary ;
 IN: tar
 
 : zero-checksum 256 ;
@@ -94,7 +94,7 @@ TUPLE: unimplemented-typeflag header ;
 
 ! Normal file
 : typeflag-0
-  tar-header-name tar-path+ <file-writer>
+  tar-header-name tar-path+ binary <file-writer>
   [ read-data-blocks ] keep dispose ;
 
 ! Hard link
@@ -236,7 +236,7 @@ TUPLE: unimplemented-typeflag header ;
     ] when* ;
 
 : parse-tar ( path -- obj )
-    [
+    binary [
         "tar-test" resource-path base-dir set
         global [ nl nl nl "Starting to parse .tar..." print flush ] bind
         global [ "Expanding to: " write base-dir get . flush ] bind
index 7c28983519de4861da81be95a5d689a8b2fa00d3..63f9a087f52519df4d16292f2513b4e7fa068cac 100755 (executable)
@@ -5,12 +5,12 @@ words vocabs vocabs.loader definitions parser continuations
 inspector debugger io io.styles io.streams.lines hashtables
 sorting prettyprint source-files arrays combinators strings
 system math.parser help.markup help.topics help.syntax
-help.stylesheet memoize ;
+help.stylesheet memoize io.encodings.utf8 ;
 IN: tools.browser
 
 MEMO: (vocab-file-contents) ( path -- lines )
     ?resource-path dup exists?
-    [ file-lines ] [ drop f ] if ;
+    [ utf8 file-lines ] [ drop f ] if ;
 
 : vocab-file-contents ( vocab name -- seq )
     vocab-path+ dup [ (vocab-file-contents) ] when ;
@@ -18,7 +18,7 @@ MEMO: (vocab-file-contents) ( path -- lines )
 : set-vocab-file-contents ( seq vocab name -- )
     dupd vocab-path+ [
         ?resource-path
-        [ [ print ] each ] with-file-writer
+        utf8 [ [ print ] each ] with-file-writer
     ] [
         "The " swap vocab-name
         " vocabulary was not loaded from the file system"
index eb1a4af4a7f45dc7ae57087d17982e0c620f5369..e4a0d539d14234b3c9bd16a0d0726c26d8ad6412 100755 (executable)
@@ -46,8 +46,8 @@ IN: tools.deploy.macosx
     ] H{ } make-assoc print-plist ;
 
 : create-app-plist ( vocab bundle-name -- )
-    dup "Contents/Info.plist" path+ <file-writer>
-    [ print-app-plist ] with-stream ;
+    dup "Contents/Info.plist" path+
+    utf8 [ print-app-plist ] with-file-writer ;
 
 : create-app-dir ( vocab bundle-name -- vm )
     dup "Frameworks" copy-bundle-dir
index 833a6e75483468c09752bff855085b06253713e2..57fe7b43e8a562da6cd8f15e5331961074ae3c75 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.files io words alien kernel math.parser alien.syntax
 io.launcher system assocs arrays sequences namespaces qualified
-system math windows.kernel32 generator.fixup ;
+system math windows.kernel32 generator.fixup io.encodings.ascii ;
 IN: tools.disassembler
 
 : in-file "gdb-in.txt" resource-path ;
@@ -15,7 +15,7 @@ M: word make-disassemble-cmd
     word-xt code-format - 2array make-disassemble-cmd ;
 
 M: pair make-disassemble-cmd
-    in-file [
+    in-file ascii [
         "attach " write
         current-process-handle number>string print
         "disassemble " write
@@ -28,7 +28,7 @@ M: pair make-disassemble-cmd
         out-file +stdout+ set
         [ "gdb" , "-x" , in-file , "-batch" , ] { } make +arguments+ set
     ] { } make-assoc run-process drop
-    out-file file-lines ;
+    out-file ascii file-lines ;
 
 : tabs>spaces ( str -- str' )
     { { CHAR: \t CHAR: \s } } substitute ;
index 2dade0f58e377af0eb87be75ffbcbb907691d32b..8078ec4a338fd1161dfcc50fb4e5a144920473b0 100755 (executable)
@@ -73,7 +73,7 @@ M: freetype-renderer free-fonts ( world -- )
 
 : open-face ( font style -- face )
     ttf-name ttf-path
-    dup file-contents >byte-array malloc-byte-array
+    dup malloc-file-contents
     swap file-length
     (open-face) ;
 
index 1014d3ad7ea9cdfc2ac0ef3a3c1ecce04606b019..dfc7bf2264eb1f1d9eb6327d3b27a7fa8d2ed85f 100644 (file)
@@ -1,7 +1,7 @@
 USING: unicode.categories kernel math combinators splitting
 sequences math.parser io.files io assocs arrays namespaces
 combinators.lib assocs.lib math.ranges unicode.normalize
-unicode.syntax unicode.data compiler.units alien.syntax ;
+unicode.syntax unicode.data compiler.units alien.syntax io.encodings.ascii ;
 IN: unicode.breaks
 
 C-ENUM: Any L V T Extend Control CR LF graphemes ;
@@ -30,7 +30,7 @@ CATEGORY: grapheme-control Zl Zp Cc Cf ;
     concat >set ;
 
 : other-extend-lines ( -- lines )
-    "extra/unicode/PropList.txt" resource-path file-lines ;
+    "extra/unicode/PropList.txt" resource-path ascii file-lines ;
 
 VALUE: other-extend
 
index c3998a613282734d04ca72d93943a477935d27a4..11be803893abfbd72001ecdad928f464e7d8417e 100755 (executable)
@@ -1,6 +1,6 @@
 USING: assocs math kernel sequences io.files hashtables
 quotations splitting arrays math.parser combinators.lib hash2
-byte-arrays words namespaces words compiler.units parser ;
+byte-arrays words namespaces words compiler.units parser io.encodings.ascii  ;
 IN: unicode.data
 
 <<
@@ -21,7 +21,7 @@ IN: unicode.data
 ! Loading data from UnicodeData.txt
 
 : data ( filename -- data )
-    file-lines [ ";" split ] map ;
+    ascii file-lines [ ";" split ] map ;
 
 : load-data ( -- data )
     "extra/unicode/UnicodeData.txt" resource-path data ;
index 552f5e0977b7e4a72b34c9d907c045512f74a548..12627b985f97616ea0b7efc91a6a500f005723d7 100755 (executable)
@@ -3,7 +3,7 @@
 USING: calendar html io io.files kernel math math.parser
 http.server.responders http.server.templating namespaces parser
 sequences strings assocs hashtables debugger http.mime sorting
-html.elements logging ;
+html.elements logging io.encodings.binary ;
 
 IN: webapps.file
 
@@ -37,7 +37,7 @@ SYMBOL: serve-file-hook
 [
     dupd
     file-response
-    <file-reader> stdio get stream-copy
+    binary <file-reader> stdio get stream-copy
 ] serve-file-hook set-global
 
 : serve-static ( filename mime-type -- )
index 4c0701c6877e9761583024d9b9bc420b94f742bf..dc97805b78e8fdb90513d03ffc9058d937609da8 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.files namespaces webapps.file http.server.responders
-xmode.code2html kernel html sequences ;
+xmode.code2html kernel html sequences io.encodings.utf8 ;
 IN: webapps.source
 
 ! This responder is a potential security problem. Make sure you
@@ -15,7 +15,7 @@ IN: webapps.source
 : source-responder ( path mime-type -- )
     drop
     serving-html
-    [ dup <file-reader> htmlize-stream ] with-html-stream ;
+    [ dup utf8 <file-reader> htmlize-stream ] with-html-stream ;
 
 global [
     ! Serve up our own source code
index ec3e24b99de96dc84ba9cb30f73634a41e20b238..970ff39cf1dca0b6f31dccdfb39c24622b1bf6b7 100644 (file)
@@ -3,7 +3,7 @@
 USING: io io.streams.string io.files kernel math namespaces
 prettyprint sequences arrays generic strings vectors
 xml.char-classes xml.data xml.errors xml.tokenize xml.writer
-xml.utilities state-parser assocs ascii ;
+xml.utilities state-parser assocs ascii io.encodings.utf8 ;
 IN: xml
 
 !   -- Overall parser with data tree
@@ -167,7 +167,8 @@ TUPLE: pull-xml scope ;
     <string-reader> read-xml ;
 
 : file>xml ( filename -- xml )
-    <file-reader> read-xml ;
+    ! Autodetect encoding!
+    utf8 <file-reader> read-xml ;
 
 : xml-reprint ( string -- )
     string>xml print-xml ;
index d6402603fa24df1cd0c023ded4bc2124d86575a5..6bff786fff2a6acde446b4d167c61bbc8420b495 100755 (executable)
@@ -1,6 +1,6 @@
 USING: xmode.loader xmode.utilities xmode.rules namespaces
 strings splitting assocs sequences kernel io.files xml memoize
-words globs combinators ;
+words globs combinators io.encodings.utf8 ;
 IN: xmode.catalog
 
 TUPLE: mode file file-name-glob first-line-glob ;
@@ -25,7 +25,7 @@ TAGS>
 
 : load-catalog ( -- modes )
     "extra/xmode/modes/catalog" resource-path
-    <file-reader> read-xml parse-modes-tag ;
+    file>xml parse-modes-tag ;
 
 : modes ( -- assoc )
     \ modes get-global [
@@ -38,7 +38,7 @@ TAGS>
 MEMO: (load-mode) ( name -- rule-sets )
     modes at mode-file
     "extra/xmode/modes/" swap append
-    resource-path <file-reader> parse-mode ;
+    resource-path utf8 <file-reader> parse-mode ;
 
 SYMBOL: rule-sets
 
index 3db70cf2e981ea1a9c0b6995d5351001737115ff..47e619cc005c75e092212690bf338e33ed2314db 100755 (executable)
@@ -1,5 +1,5 @@
 USING: xmode.tokens xmode.marker xmode.catalog kernel html html.elements io
-    io.files sequences words ;
+    io.files sequences words io.encodings.utf8 ;
 IN: xmode.code2html
 
 : htmlize-tokens ( tokens -- )
@@ -20,7 +20,7 @@ IN: xmode.code2html
 : default-stylesheet ( -- )
     <style>
         "extra/xmode/code2html/stylesheet.css"
-        resource-path file-contents write
+        resource-path utf8 file-contents write
     </style> ;
 
 : htmlize-stream ( path stream -- )
@@ -40,5 +40,5 @@ IN: xmode.code2html
     </html> ;
 
 : htmlize-file ( path -- )
-    dup <file-reader> over ".html" append <file-writer>
+    dup utf8 <file-reader> over ".html" append utf8 <file-writer>
     [ htmlize-stream ] with-stream ;
index 22ea687a290db9763f40e5723314b2774b8dea9f..197fa4900b3cd68473f158dfa8c39986d8877778 100644 (file)
@@ -6,6 +6,6 @@ USING: tools.test yahoo kernel io.files xml sequences ;
     "Official Foo Fighters"
     "http://www.foofighters.com/"
     "Official site with news, tour dates, discography, store, community, and more."
-} ] [ "extra/yahoo/test-results.xml" resource-path <file-reader> read-xml parse-yahoo first ] unit-test
+} ] [ "extra/yahoo/test-results.xml" resource-path file>xml parse-yahoo first ] unit-test
 
 [ "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=Factor-search&query=hi&results=1" ] [ "hi" 1 query ] unit-test