0

I want to return the utf-8 tick character ✔ ✔ in my ruby method.

I reason I am doing it in my method is because I need that character in an excel column generated by rails axlsx.

I know we can use the content_tag to return html block tag, but not sure how I can use it to return the utf-8 character. If there is an alternative can someone please suggest me one.

newbie
  • 1,023
  • 20
  • 46

2 Answers2

3

You could just return the "✔" String, if you have utf-8 encoded source file I'm fairly certain that works. Alternatively, you can use "\u{codepoint}" to return a unicode character of a specific codepoint. That codepoint in your case is 2714 (hex), so you can do:

def checkmark
  "\u{2714}"
end
Daniël Knippers
  • 3,049
  • 1
  • 11
  • 17
2

That's easy:

def my_method
  '✔'
end
Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653