Hello ,

i have an .js file to fetch title and description from another site have utf8 charset and my site also have utf8 charset

it fetch english character well but arabic or turki character it appear such that ????????? ???? ????????

.js content

function request_videoinfo()
{
	if (!fetch_object('videourl').value)
	{
		return false;
	}

	YAHOO.util.Connect.asyncRequest("POST", "video.php?do=videoinfo", {
		success: handel_videoinfo,
		failure: vBulletin_AJAX_Error_Handler,
		timeout: 15000
	}, SESSIONURL + 'securitytoken=' + SECURITYTOKEN + "&url=" + PHP.urlencode(fetch_object('videourl').value) + "&wysiwyg=" + vB_Editor[editor_id].wysiwyg_mode);

	fetch_object('videoajaxbutton').value = vbphrase['requesting_information_please_wait'];
	fetch_object('videoajaxbutton').disabled = true;

	return false;
}

function handel_videoinfo(ajax)
{
	if (ajax.responseXML)
	{
		// check for error first
		var error = ajax.responseXML.getElementsByTagName('error');
		if (error.length)
		{
			fetch_object('thumbnail').setAttribute('src', '');
			fetch_object('thumbnail_border').style.display = 'none';
			alert(error[0].firstChild.nodeValue);
		}
		else
		{
			try
			{
				var description = ajax.responseXML.getElementsByTagName('description')[0].firstChild.nodeValue;
				vB_Editor[editor_id].insert_text(description);
			}
			catch (e)
			{
			}

			try
			{
				var title = ajax.responseXML.getElementsByTagName('title')[0].firstChild.nodeValue;
				fetch_object('videotitle').value = title;
			}
			catch (e)
			{
			}

			try
			{
				var videothumbnailpath = ajax.responseXML.getElementsByTagName('thumbnailpath')[0].firstChild.nodeValue;
				fetch_object('thumbnail').setAttribute('src', videothumbnailpath);
				fetch_object('thumbnail_border').style.display = '';
			}
			catch (e)
			{
			}
		}
	}
	fetch_object('videoajaxbutton').value = vbphrase['request_videoinfo_from_service'];
	fetch_object('videoajaxbutton').disabled = false;
}

Proper encoding headers need to be set when requesting and serving the resource e.g. Content-Type and Content-Encoding. Just having utf-8 charset doesn't mean the content is not encoded in some other encoding. Inspect the requested .js file in a unicode aware text editor and see if it really is unicode encoded or just platform default encoded data served with a unicode encoding.

Encoding related issues mostly revolve around incorrect encoding used when serving data or having data which isn't utf encoded and being served as unicode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.