Hi, I updated to the latest version of julia yesterday and now I encounter
a problem with map.
I have an utf8 file that contains two lines, with a word made of ascii
chars on the first line and with some utf8 chars on the second line. I read
the file using readlines and try to reverse the strings in the resulting
array, as follows.
$ cat temp
ascii
touché
julia> data = open(readlines, "temp")
2-element Array{Union(UTF8String,ASCIIString),1}:
"ascii\n"
"touché\n"
julia> map(reverse, data)
ERROR: invalid ASCII sequence
in setindex! at array.jl:298
in map_to! at abstractarray.jl:1255
This was working in a previous version of julia circa january (and probably
still working on 0.2). I am not sure what has changed, map or readlines?
And what are these changes?
Note that everything is fine if I first upgrade the data to the UTF8String
type.
julia> map(reverse, map(utf8, data))
2-element Array{UTF8String,1}:
"\niicsa"
"\néhcuot"
but this can't be done directly.
julia> convert(Array(UTF8String,1), data)
ERROR: no method convert(Array{UTF8String,1},
Array{Union(UTF8String,ASCIIString),1})
in convert at base.jl:13