Class: GObjectIntrospection::TypeTag::UTF8

Inherits:
Object
  • Object
show all
Defined in:
lib/gobject-introspection/type-tag.rb

Class Method Summary collapse

Class Method Details

.try_convert(type_info, value) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/gobject-introspection/type-tag.rb', line 83

def try_convert(type_info, value)
  case value
  when String
    value.encode(Encoding::UTF_8)
  when Symbol
    value.to_s.encode(Encoding::UTF_8)
  else
    if value.respond_to?(:to_str)
      value.to_str.encode(Encoding::UTF_8)
    else
      nil
    end
  end
end