From: Ammar Ali Date: 2010-11-11T07:34:27+09:00 Subject: Re: Short question about encoding. On Thu, Nov 11, 2010 at 12:01 AM, Gabriel Lichard wrote: > Hello everybody at the Ruby Forums! > > After getting more into Ruby I stumbled across a little problem: how > would I go about making a string with a "square root" sign (√) inside > it, so that it gets encoded in UTF-8 and so that I can later save it in > a file? > > Also, I read that Ruby does have encoding-related issues, so, if that's > the case, I can probably live without the "square root" sign. > > puts "√".encode("UTF-8") # converts it into a "v" > puts "√"                 # -//- > puts "√".force_encoding("UTF-8") # -//- > > Any ideas, please? One possibility is using the hex codes for that code point, like: "\xE2\x88\x9A" There is also a unicode escape, \u. For more information, take a look at: http://ruby.runpaint.org/strings#escapes-summary HTH, Ammar