Method: Sass::Script::Value::String.value

Defined in:
lib/sass/script/value/string.rb

.value(contents)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sass/script/value/string.rb', line 19

def self.value(contents)
  contents.gsub("\\\n", "").gsub(/\\(?:([0-9a-fA-F]{1,6})\s?|(.))/) do
    next $2 if $2
    # Handle unicode escapes as per CSS Syntax Level 3 section 4.3.8.
    code_point = $1.to_i(16)
    if code_point == 0 || code_point > 0x10FFFF ||
        (code_point >= 0xD800 && code_point <= 0xDFFF)
      '�'
    else
      [code_point].pack("U")
    end
  end
end