954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

UTf-8 fetch title an description problem

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;
}
ma3hd
Newbie Poster
2 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

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.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You