bill_cosby bill_cosby - 4 months ago 17
Ruby Question

Read a csv file containing special characters(different spoken language)

I'm writing a csv file in Hindi(language), when I parse it I get different results.

For example, I make below csv file.

1234444070;आज आप कैसे हैं???


When I read the same file using
open(csv_aws_url).read
. I get:

"1234444070;\xE0\xA4\x86\xE0\xA4\x9C \xE0\xA4\x86\xE0\xA4\xAA \xE0\xA4\x95\xE0\xA5\x88\xE0\xA4\xB8\xE0\xA5\x87 \xE0\xA4\xB9\xE0\xA5\x88\xE0\xA4\x82???\r\n"


Can this happen that I read the same contents while parsing?

Answer
open(csv_aws_url).read.force_encoding('utf-8')