On Wednesday, August 17, 2016 at 1:52:47 PM UTC-4, Rishabh Raghunath wrote:
>
> For Example: Writing a Encrypting program requires me to modify the 
> characters in the string..
>

This is a pretty bad example, because encryption almost always (a) doesn't 
work in-place and (b) only looks at raw bytes (ignoring whether they are 
"characters").

Similarly lot of the very low-level C-like operations that you might want 
to do actually involve raw bytes, and so you are better off working with a 
byte array, which you can obtain by Vector{UInt8}(some string) and can 
subsequently convert to a string via String(some byte array).

If you are creating a string incrementally, you can do that (roughly) 
in-place with an IOBuffer() as Jacob mentioned.

A lot of things that you might *think* are do-able in-place, like 
converting a string to upper-case, are actually *not* possible to do 
in-place if you have non-ASCII data, because strings are typically stored 
in a variable-length encoding (UTF-8 is the default in Julia).

 

Reply via email to