I'm a beginner working on a simple Ruby program to generate vocabulary lists from text files. Spanish allows words to carry stress marks on capitalized first letters (e.g. "Ábaco"), but I want all words in my list to be downcased. Right now, if I try "Á".downcase
the console returns "Á".
Is there a way to use upcase & downcase in ruby with accented characters in Spanish (áéíóúñ)?
This is what my program presently looks like:
f = File.open(".../cat.txt")
words = f.read.split.map(&:downcase)
f.close
words = words.map {|item| item.gsub(/[,.?!-"'"]/, '')}
words = words.uniq.sort
File.open(".../catwords.txt", "w+") do |f|
words.each { |element| f.puts(element) }
end