class CFPropertyList::CFString

This class holds string values, both, UTF-8 and UTF-16BE It will convert the value to UTF-16BE if necessary (i.e. if non-ascii char contained)

Public Instance Methods

quoted() click to toggle source
# File lib/cfpropertylist/rbCFTypes.rb, line 69
def quoted
  str = '"'
  @value.each_char do |c|
    str << case c
    when '"'
      '\"'
    when '\'
      '\'
    when "\a"
      "\\a"
    when "\b"
      "\\b"
    when "\f"
      "\\f"
    when "\n"
      "\n"
    when "\v"
      "\\v"
    when "\r"
      "\\r"
    when "\t"
      "\\t"
    else
      c
    end
  end

  str << '"'
end
to_binary(bplist) click to toggle source

convert to binary

# File lib/cfpropertylist/rbCFTypes.rb, line 57
def to_binary(bplist)
  bplist.string_to_binary(@value);
end
to_plain(plist) click to toggle source
# File lib/cfpropertylist/rbCFTypes.rb, line 61
def to_plain(plist)
  if @value =~ /^\w+$/
    @value
  else
    quoted
  end
end
to_xml(parser) click to toggle source

convert to XML

# File lib/cfpropertylist/rbCFTypes.rb, line 50
def to_xml(parser)
  n = parser.new_node('string')
  n = parser.append_node(n, parser.new_text(@value)) unless @value.nil?
  n
end