Class: String

Inherits:
Object show all
Defined in:
lib/pybind/core_ext/basic.rb

Instance Method Summary collapse

Instance Method Details

#to_pythonObject



39
40
41
42
43
44
45
46
47
# File 'lib/pybind/core_ext/basic.rb', line 39

def to_python
  case encoding
  when Encoding::US_ASCII, Encoding::BINARY
    PyBind::LibPython.PyString_FromStringAndSize(self, bytesize)
  else
    utf8_str = encode(Encoding::UTF_8)
    PyBind::LibPython.PyUnicode_DecodeUTF8(utf8_str, utf8_str.bytesize, nil)
  end
end