res = INTL_ConvertCharset(charset, "UTF-8", rsrcString, PL_strlen(rsrcString),
res = INTL_ConvertCharset(charset, "UTF-8", rsrcString, nsCRT::strlen(rsrcString),
static int OutputButtons(MimeObject *obj, PRBool basic, VObject *v){	int status = 0;	char * htmlLine1 = NULL;	char * htmlLine2 = NULL;	char* vCard = NULL;	char* vEscCard = NULL;	int len = 0;	char* charset = NULL;	char* rsrcString = NULL;	char* converted = NULL;  PRInt32 converted_length;  PRInt32   res;	if (!obj->options->output_vcard_buttons_p)		return status;	vCard = writeMemVObjects(0, &len, v);	if (!vCard)		return VCARD_OUT_OF_MEMORY;	vEscCard = nsEscape (vCard, url_XAlphas);	PR_FREEIF (vCard);	if (!vEscCard)		return VCARD_OUT_OF_MEMORY;	/* parse a content type for the charset */	charset = PL_strstr(obj->content_type, "charset=");  if (!charset)    charset = "ISO-8859-1";	if (basic)	{		rsrcString = VCardGetStringByID(VCARD_ADDR_VIEW_COMPLETE_VCARD);		// convert from the resource charset.     res = INTL_ConvertCharset(charset, "UTF-8", rsrcString, PL_strlen(rsrcString),                               &converted, &converted_length);    if ( (res != 0) || (converted == NULL) )			converted = rsrcString;    htmlLine1 = PR_smprintf ("<FORM name=form1><INPUT type=reset value=\\\"%s\\\" onClick=\\\"showAdvanced%d();\\\"></INPUT></FORM>", 			                        converted, s_unique);	}	else 	{		rsrcString = VCardGetStringByID(VCARD_ADDR_VIEW_CONDENSED_VCARD);    res = INTL_ConvertCharset(charset, "UTF-8", rsrcString, PL_strlen(rsrcString),                               &converted, &converted_length);    if ( (res != 0) || (converted == NULL) )			converted = rsrcString;		htmlLine1 = PR_smprintf ("<FORM name=form1><INPUT type=reset value=\\\"%s\\\" onClick=\\\"showBasic%d();\\\"></INPUT></FORM>", 			converted, s_unique);	}	if (converted != rsrcString)  {		PR_FREEIF(converted);  }  else  {    PR_FREEIF(rsrcString);  }	rsrcString = VCardGetStringByID(VCARD_MSG_ADD_TO_ADDR_BOOK);  res = INTL_ConvertCharset(charset, "UTF-8", rsrcString, PL_strlen(rsrcString),                             &converted, &converted_length);  if ( (res != 0) || (converted == NULL) )		converted = rsrcString;	htmlLine2 = PR_smprintf ("<FORM name=form1 METHOD=get ACTION=\"addbook:add\"><INPUT TYPE=hidden name=vcard VALUE=\"%s\"><INPUT type=submit value=\"%s\"></INPUT></FORM>",		vEscCard, converted);	if (converted != rsrcString)  {		PR_FREEIF(converted);  }  else  {    PR_FREEIF(rsrcString);  }	if (!htmlLine1 && !htmlLine2)	{		nsCRT::free (vEscCard);		PR_FREEIF (htmlLine1);		PR_FREEIF (htmlLine2);		return VCARD_OUT_OF_MEMORY;	}		status = OutputTableRowOrData (obj, PR_FALSE, PR_FALSE, "LEFT", "TOP", NULL, NULL);	if (status < 0) goto FAIL;	/*	 * WARNING: This HTML is written to the stream using JavaScript,	 * because we don't want this button to be displayed when JS has	 * been switched off (in the whole client or just in email). The	 * button won't work when JS is switched off (since it calls a JS	 * function), so then we don't want the button to be displayed.	 *   -- erik (and jfriend)	 */	status = WriteEachLineToStream (obj, "<SCRIPT>document.write(\"");	if (status < 0) goto FAIL;	status = WriteLineToStream (obj, htmlLine1);	if (status < 0) goto FAIL;	status = WriteEachLineToStream (obj, "\")</SCRIPT>");	if (status < 0) goto FAIL;	status = WriteLineToStream (obj, htmlLine2);	if (status < 0) goto FAIL;	status = OutputTableRowOrData (obj, PR_FALSE, PR_TRUE, NULL, NULL, NULL, NULL);	if (status < 0) goto FAIL;	FAIL:	PR_FREEIF (vEscCard);	PR_FREEIF (htmlLine1);	PR_FREEIF (htmlLine2);	return status;}