Enumerate each character as a 1-character string
s = "A\nB" # Three ASCII characters on two lines
# This does not work for multibyte strings in 1.8
# It works (inefficiently) for multibyte strings in 1.9:
0.upto(s.length-1) {|n| print s[n,1], " "}
Related examples in the same category