: load-encoding ( name iana-name file-name -- )
[ create-encoding dup ]
[ register-encoding ]
- [ encoding-file flat-file>biassoc 8-bit boa ] tri*
+ [ encoding-file load-codetable-file 8-bit boa ] tri*
swap 8-bit-encodings get-global set-at ;
PRIVATE>
: setup-euc ( word file-name -- singleton-class biassoc )
[ dup define-singleton-class ]
- [ flat-file>biassoc ] bi* ;
+ [ load-codetable-file ] bi* ;
:: define-recursive-methods ( class data words -- )
words [| word |
SYMBOL: jis208
SYMBOL: jis212
-"vocab:io/encodings/iso2022/201.txt" flat-file>biassoc jis201 set-global
-"vocab:io/encodings/iso2022/208.txt" flat-file>biassoc jis208 set-global
-"vocab:io/encodings/iso2022/212.txt" flat-file>biassoc jis212 set-global
+"vocab:io/encodings/iso2022/201.txt" load-codetable-file jis201 set-global
+"vocab:io/encodings/iso2022/208.txt" load-codetable-file jis208 set-global
+"vocab:io/encodings/iso2022/212.txt" load-codetable-file jis212 set-global
SYMBOL: ascii
128 iota dup zip >biassoc ascii set-global
: jis>ch ( jis tuple -- string ) assoc>> at replacement-char or ;
: make-jis ( filename -- jis )
- flat-file>biassoc sift-values jis boa ;
+ load-codetable-file sift-values jis boa ;
"vocab:io/encodings/shift-jis/CP932.txt"
make-jis windows-31j-table set-global
ARTICLE: "simple-flat-file" "Parsing simple flat files"
"The " { $vocab-link "simple-flat-file" } " vocabulary provides words for loading and parsing simple flat files in a particular format which is common for encoding and Unicode tasks."
{ $subsections
- flat-file>biassoc
+ load-codetable-file
load-interval-file
load-data-file
} ;
{ $values { "filename" string } { "data" array } }
{ $description "This loads a file that's delineated by semicolons and lines, returning an array of lines, where each line is an array split by the semicolons, with whitespace trimmed off." } ;
-HELP: flat-file>biassoc
+HELP: load-codetable-file
{ $values { "filename" string } { "biassoc" biassoc } }
{ $description "This loads a flat file, in the form that many encoding resource files are in, with two columns of numeric data in hex, and returns a biassoc associating them." } ;
MEMO: <test1> ( -- code-table )
- "vocab:simple-flat-file/test1.txt" flat-file>biassoc ;
+ "vocab:simple-flat-file/test1.txt" load-codetable-file ;
{ 0 } [ 0 <test1> at ] unit-test
{ 0 } [ 0 <test1> value-at ] unit-test
: process-codetable-lines ( lines -- assoc )
drop-comments [ parse-line ] map! ;
-: flat-file>biassoc ( filename -- biassoc )
+: load-codetable-file ( filename -- biassoc )
utf8 file-lines process-codetable-lines >biassoc ;
: split-; ( line -- array )