    /*
     * call-seq:
     *  encode_special_chars(string)
     *
     * Encode any special characters in +string+
     */
    static VALUE encode_special_chars(VALUE self, VALUE string)
    {
      xmlNodePtr node;
      xmlChar *encoded;
      VALUE encoded_str;

      Data_Get_Struct(self, xmlNode, node);
      encoded = xmlEncodeSpecialChars(
          node->doc,
          (const xmlChar *)StringValuePtr(string)
      );

      encoded_str = NOKOGIRI_STR_NEW2(encoded);
      xmlFree(encoded);

      return encoded_str;
    }