code: def _check_str_value(x):
      """If string has a space, wrap it in double quotes and remove/escape illegal characters"""
      if isinstance(x, str):
          # remove commas, and single quotation marks since loadarff cannot deal with it
          x = (
              x.replace(",", ".")
              .replace(chr(0x2018), "'")
              .replace(chr(0x2019), "'")
          )
  
          # put string in double quotes
          if " " in x:
              if x[0] in ('"', "'"):
                  x = x[1:]
              if x[-1] in ('"', "'"):
                  x = x[: len(x) - 1]
              x = '"' + x.replace('"', '\\"') + '"'
      return str(x)
  
file_path: scikit-survival/sksurv/io/arffwrite.py
imports: import os.path
  import re
  import numpy
  import pandas
  from pandas.api.types import CategoricalDtype, is_object_dtype
label_desc: Use image node_id 4 for calling a global function with example usage: _check_str_value(x) and returns: str