Module: LeBonCoin::HTMLUtils

Defined in:
lib/leboncoin/htmlutils.rb

Class Method Summary collapse

Class Method Details

.convert(str) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/leboncoin/htmlutils.rb', line 4

def convert str
  require 'htmlentities'
  str = HTMLEntities.new.encode(str.force_encoding("ISO-8859-15").encode("UTF-8"), :hexadecimal)
    .gsub(/é/, "é")
    .gsub(/™/, "™")
    .gsub(/®/, "©")

  str = HTMLEntities.new.decode(str)
    .gsub(/\u0092/, "'")
    .gsub(/\u0096/, "-")
    .gsub(/\u0095/, "•")
    .gsub(/\u0099/, "™")
    .gsub(/\u0080/, "€")

  return str
end