user1120144
user1120144

Reputation:

How to convert a unicode string to its symbol characters in Ruby?

I have the following string:

Ruby :: \u041D\u043E\u0432\u0438\u043D\u0438

My question is how to convert it to utf8 characters (in my case cyrilic letters)?

Upvotes: 2

Views: 7298

Answers (1)

rossta
rossta

Reputation: 11494

In Ruby 1.9:

"\u041D\u043E\u0432\u0438\u043D\u0438".encode("UTF-8")
=> "Новини" 

Upvotes: 8

Related Questions