code: def write_char(self, arr, name):
      arr = arr_to_chars(arr)
      arr = arr_to_2d(arr, self.oned_as)
      dims = arr.shape
      self.write_header(name, dims, P=miUINT8, T=mxCHAR_CLASS)
      if arr.dtype.kind == "U":
          # Recode unicode to latin1
          n_chars = np.product(dims)
          st_arr = np.ndarray(
              shape=(), dtype=arr_dtype_number(arr, n_chars), buffer=arr
          )
          st = st_arr.item().encode("latin-1")
          arr = np.ndarray(shape=dims, dtype="S1", buffer=st)
      self.write_bytes(arr)
  
imports: from __future__ import division, print_function, absolute_import
  import sys
  import warnings
  import numpy
  from numpy.compat import asbytes, asstr
  import scipy.sparse
  from scipy._lib.six import string_types
  from .miobase import MatFileReader, docfiller, matdims, read_dtype, convert_dtypes, arr_to_chars, arr_dtype_number
  from .mio_utils import squeeze_element, chars_to_strings
  from functools import reduce
label_desc: Use image node_id 7 for calling the VarWriter4 obj's underlying member method code with example usage: obj.write_char(arr, name) without return types