Debian Codegraph @

terps/tads/tads3/test/data/unicode_file.t

raw
1 /*
2 * files.t - test of file I/O operations
3 */
4
5 #include "tads.h"
6 #include "t3.h"
7 #include "bytearr.h"
8 #include "file.h"
9 #include "bignum.h"
10
11
12 main(args)
13 {
14 local fpIn, fpOut;
15
16 /* open a file */
17 try
18 {
19 fpIn = File.openTextFile('unicode_text_chars.txt',
20 FileAccessRead, 'utf-16le');
21 }
22 catch (FileException fExc)
23 {
24 "Error opening input file: <<fExc.displayException()>>\n";
25 return;
26 }
27
28 /* open the output file */
29 try
30 {
31 fpOut = File.openTextFile('unicode_out.txt',
32 FileAccessWrite, 'utf-16le');
33 }
34 catch (FileException fExc)
35 {
36 "Error opening output file: <<fExc.displayException()>>\n";
37 return;
38 }
39
40 /* copy the file */
41 for (;;)
42 {
43 /* read a line */
44 local val = fpIn.readFile();
45 if (val == nil)
46 break;
47
48 /* write it out */
49 fpOut.writeFile(val);
50 }
51
52 /* close the files */
53 fpIn.closeFile();
54 fpOut.closeFile();
55
56 /* done */
57 "Done!\n";
58 }
59