@@ -36,27 +36,26 @@ julia> decode(ans, "UTF-16")
36
36
Use the ` encodings ` function to get the list of all supported encodings on the current platform:
37
37
``` julia
38
38
julia> encodings ()
39
- 1241 - element Array{String,1 }:
40
- " 1026"
41
- " 1046"
42
- " 1047"
43
- " 10646-1:1993"
44
- " 10646-1:1993/UCS4"
45
- " 437"
46
- " 500"
47
- " 500V1"
48
- " 850"
49
- " 851"
50
- ⋮
51
- " windows-1258"
52
- " WINDOWS-1258"
53
- " WINDOWS-31J"
54
- " windows-874"
55
- " WINDOWS-874"
56
- " WINDOWS-936"
57
- " WINSAMI2"
58
- " WS2"
59
- " YU"
39
+ 411 - element Array{String,1 }:
40
+ " 850"
41
+ " 862"
42
+ " 866"
43
+ " ANSI_X3.4-1968"
44
+ " ANSI_X3.4-1986"
45
+ " ARABIC"
46
+ " ARMSCII-8"
47
+ " ASCII"
48
+ " ASMO-708"
49
+ ⋮
50
+ " WINDOWS-1257"
51
+ " windows-1258"
52
+ " WINDOWS-1258"
53
+ " windows-874"
54
+ " WINDOWS-874"
55
+ " WINDOWS-936"
56
+ " X0201"
57
+ " X0208"
58
+ " X0212"
60
59
```
61
60
62
61
(Note that many of these are aliases for standard names.)
@@ -77,15 +76,15 @@ julia> path = tempname();
77
76
78
77
julia> f = open (path, enc " UTF-16" , " w" );
79
78
80
- julia> write (f, " café\n noël" )
79
+ julia> write (f, " café\n noël" );
81
80
82
81
julia> close (f); # Essential to complete encoding
83
82
```
84
83
85
84
The contents of the file can then be read back using ` read(path, String) ` :
86
85
``` julia
87
86
julia> read (path, String) # Standard function expects UTF-8
88
- " \U 3d83f7c0f \0 澊 \ 0 n\0 o\0 迬 \0 "
87
+ " \x fe \x ff \0 c \0 a \0 f \0\x e9 \0\n\ 0 n\0 o\0\x eb \0 l "
89
88
90
89
julia> read (path, String, enc " UTF-16" ) # Works when passing the correct encoding
91
90
" café\n noël"
@@ -94,20 +93,20 @@ julia> read(path, String, enc"UTF-16") # Works when passing the correct encoding
94
93
Other variants of standard convenience functions are provided:
95
94
``` julia
96
95
julia> readline (path, enc " UTF-16" )
97
- " café\n "
96
+ " café"
98
97
99
98
julia> readlines (path, enc " UTF-16" )
100
99
2 - element Array{String,1 }:
101
- " café\n "
100
+ " café"
102
101
" noël"
103
102
104
103
julia> for l in eachline (path, enc " UTF-16" )
105
- print (l)
104
+ println (l)
106
105
end
107
106
café
108
107
noël
109
108
110
- julia> readuntil (path, enc " UTF-16" , " o " )
109
+ julia> readuntil (path, enc " UTF-16" , " ë " )
111
110
" café\n no"
112
111
```
113
112
@@ -121,6 +120,8 @@ julia> read(io, String)
121
120
122
121
In particular, this method allows reading encoded comma-separated values (CSV) and other character-delimited text files:
123
122
``` julia
123
+ julia> using DelimitedFiles
124
+
124
125
julia> open (readcsv, path, enc " UTF-16" )
125
126
2 x1 Array{Any,2 }:
126
127
" café"
0 commit comments