Skip to content

Commit b1e6668

Browse files
committed
Update README.md
1 parent 5def787 commit b1e6668

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,26 @@ julia> decode(ans, "UTF-16")
3636
Use the `encodings` function to get the list of all supported encodings on the current platform:
3737
```julia
3838
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"
6059
```
6160

6261
(Note that many of these are aliases for standard names.)
@@ -77,15 +76,15 @@ julia> path = tempname();
7776

7877
julia> f = open(path, enc"UTF-16", "w");
7978

80-
julia> write(f, "café\nnoël")
79+
julia> write(f, "café\nnoël");
8180

8281
julia> close(f); # Essential to complete encoding
8382
```
8483

8584
The contents of the file can then be read back using `read(path, String)`:
8685
```julia
8786
julia> read(path, String) # Standard function expects UTF-8
88-
"\U3d83f7c0f\0\0n\0o\0\0"
87+
"\xfe\xff\0c\0a\0f\0\xe9\0\n\0n\0o\0\xeb\0l"
8988

9089
julia> read(path, String, enc"UTF-16") # Works when passing the correct encoding
9190
"café\nnoël"
@@ -94,20 +93,20 @@ julia> read(path, String, enc"UTF-16") # Works when passing the correct encoding
9493
Other variants of standard convenience functions are provided:
9594
```julia
9695
julia> readline(path, enc"UTF-16")
97-
"café\n"
96+
"café"
9897

9998
julia> readlines(path, enc"UTF-16")
10099
2-element Array{String,1}:
101-
"café\n"
100+
"café"
102101
"noël"
103102

104103
julia> for l in eachline(path, enc"UTF-16")
105-
print(l)
104+
println(l)
106105
end
107106
café
108107
noël
109108

110-
julia> readuntil(path, enc"UTF-16", "o")
109+
julia> readuntil(path, enc"UTF-16", "ë")
111110
"café\nno"
112111
```
113112

@@ -121,6 +120,8 @@ julia> read(io, String)
121120

122121
In particular, this method allows reading encoded comma-separated values (CSV) and other character-delimited text files:
123122
```julia
123+
julia> using DelimitedFiles
124+
124125
julia> open(readcsv, path, enc"UTF-16")
125126
2x1 Array{Any,2}:
126127
"café"

0 commit comments

Comments
 (0)