for char in a write(io, char + 1)endjulia> Base.setindex!(s::ASCIIString, v,i) = s.data[i]=v
setindex! (generic function with 58 methods)
julia> a="abc"
"abc"
julia> a[1]='7';a
"7bc"
julia> a[1]+=1;a
"8bc"
For Example: Writing a Encrypting program requires me to modify the characters in the string..
LoadError: UnicodeError: invalid character index
Last time I checked there was still some functions in Base like findlast that had such issue.The correct way to do it is to use start/done/next. That said it can become a bit tedious, when you have to reverse the string order first or so.I found that using a vector of characters is sometimes an easy solution.Note also that using a range to loop through a string is not a good idea if it might contain unicode characters.s = "a°sd2β2"for i=1:length(s)
Last time I checked there was still some functions in Base like findlast that had such issue.
I am a beginner in Julia and I am more familiar with the C language..
I am actually learning Julia for use in a programming contest and love the experience so far..
There are often questions that require you to manipulate the characters comprising the string. Its easy to do in C as strings are nothing but an array of Characters