E
E
eldar_web2016-05-06 15:46:05
Ruby on Rails
eldar_web, 2016-05-06 15:46:05

How to fix an error in Ruby when Uri.parse () when there is a Russian word inside it?

For example, I want to parse a link

https://geocode-maps.yandex.ru/1.x/?geocode=Тверская+6

Therefore I write:
url = URI.parse("https://geocode-maps.yandex.ru/1.x/?geocode=Тверская+6")

And an error is thrown:
URI::InvalidURIError: URI must be ascii only "https://geocode-maps.yandex.ru/1.x/?geocode=\u{422}\u{432}\u{435}\u{440}\u{441}\u{43a}\u{430}\u{44f}+6"

As I understand it, it's a matter of encoding.
How can this be corrected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Agaltsov, 2016-05-06
@Archusha

I didn’t touch Rubi when, but in other languages ​​there are constructions similar to urlencode.
You may need to google in that direction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question