File:  [parser3project] / parser3 / tests / 344.html
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Thu Aug 4 22:13:48 2016 UTC (9 years, 11 months ago) by moko
Branches: MAIN
CVS tags: release_3_5_1, release_3_5_0, release_3_4_6, release_3_4_5, HEAD
test for ^hash::create[$file] added (related to feature #1075)

@main[]
^from-1251[]

$f1[^file::load[binary;247_utf8_bom.txt]]
^show[f1;$f1]

$f[^file::create[$f1; $.mode[text] ]]
^show[f text from binary, automatic transcode by UTF-8 preambule;$f]

$f[^file::create[$f1; $.mode[text] $.content-type[text/plain^; charset=Windows-1251] ]]
^show[f text from binary no transcode as charset specified in content-type;$f]

$f[^file::create[$f1; $.mode[text] $.from-charset[Windows-1251] ]]
^show[f text from binary no transcode as from-charset specified;$f]

$f1[^file::load[binary;247_utf8.txt]]
^show[f1;$f1]

$f[^file::create[$f1; $.mode[text] ]]
^show[f text from binary, no transcode;$f]

$f[^file::create[$f1; $.mode[text] $.from-charset[UTF-8] ]]
^show[f text from binary transcode using from-charset;$f]

^try-catch{ ^file::create[$f1; $.to-charset[UTF-8] $.charset[UTF-8] ] }

code coverage tests:

$f1[^file::load[text;247_utf8_bom.txt; $.limit[8] $.offset[5] $.charset[UTF-8] ]]
^show[f1;$f1]

$f[^file::create[test]]
^json:string[^hash::create[$f]]

@show[title;f]
$title : {
"name":"$f.name",
"size":$f.size,
"mode":"$f.mode",
"content-type":"^taint[json;$f.content-type]",
"text":"$f.text"
}

E-mail: