getting weird symbols from yql - javascript

I'm requesting a website from yql using something like: select * from html where url="http://www.somerandomsite.com"&format=json&callback=process
The problem is I'm getting weird symbols back like: �
Is this because of yahoo or from the site that I'm using and how can I fix this?

You're probably missing a <meta> tag which defines the charset:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Related

How to fix the diamond question marks and special characters when users upload emojis

I have a JS script that uploads a JSON array to the blockchain / not a database. But when a user uploads an emoji it returns as a diamond question mark or rectangle with X etc.. Is this coming from the HTML page before the data is passed, or after the data is returned to the UI?
Ive tried adding the content type to the HTML page that both uploads the data and displays the data but theres no change. Is there something in the JS I need to change?
Heres the content types i've tried to set but didnt fix it -
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-32" />
I have a cleanser script that the data gets passed thru, maybe this is causing it?
// remove non ascii characters
replace(/\u200B/g,'');
// remove zero width space
replace(/[^\x00-\x7F]/g, '');
Any ideas here why the emojis would not get returned properly from these examples? Or is there a way to preserve the emojis in The JS script?

HTML5 - html, prefix and meta related

I am new to HTML5. I did some researches on prefix and OGP, but I still cannot figure out the following
<head prefix="og: http://ogp.me/ns#">
<title>something</title>
<meta property="og:title" content="something"/>
<meta prefix="og: http://ogp.me/ns#" property="og:image"
content="http://something.com/img/social-image.png" />
</head>
<head prefix="og: http://ogp.me/ns#">What's "og: http://ogp.me/ns#"? What does it do?
I found this from quora (https://www.quora.com/What-does-this-tag-mean-html-lang-en-US-prefix-og-http-ogp-me-ns), but I cannot understand it.
The Open Graph protocol enables any web page to become a rich object
in a social graph. For instance, this is used on Facebook to allow any
web page to have the same functionality as any other object on
Facebook.
What does "become a rich object" mean?
2.Why do we need these two lines, <title>something</title> and <meta property="og:title" content="something"/>? Aren't they same?
3.Why do we need to set the meta prefix again in the third line? Didn't we do it in the head?
<meta prefix="og: http://ogp.me/ns#" property="og:image"
content="http://something.com/img/social-image.png" />
Thanks a lot!
What you're describing is called Open Graph Protocol, and it essentially means you're using that template above to turn a webpage into a graph object. You need four parts: og:title, og:type, og:url, and og:image, which are described in detail here. This is the basic metadata you need to use Open Graph Protocol - if you don't have it, Open Graph won't work.

parsing html using Jsoup - returned document with robots meta tag

My problem is when I am using jsoup lib for parsing a specific url, it has been great till one day my parsing has corrupted, the document that has returned had some few tags which was not anything like the old document, it had meta tag named "ROBOTS".
An example of the header in the response:
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="initial-scale=1.0" />
</head>
My question is, how do you think I can overcome this block? Tried using several other libraries which parse javascript as well, but it wasnt helpful and resulted the same, maybe I didn't use it right.
(I have learnt that the meta tag robots was made for preventing bots, initially for search engines, how can I bypass this behavior? How can I act like a regular every-browser client?)
You didn't explicitly state this in your answer, but I'm assuming Jsoup is being sent different HTML than what your browser sees. In that case, you probably need to set the user agent header so Jsoup looks like your browser.

IE8 documentMode always 'quirk mode'

I'm trying to print a message to the user when he is using an IE version bellow IE8. To test it I enabled the Document Mode 8. But when I ask for the Document Mode in javascript I always receive the 'quirk mode: 5'
document.documentMode;
Does anyone know why?
Here is the beginning of my specification:
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
...
SOLVED:
I used the user-agent nevertheless and checked for the 'trident/4.0' tag which is displayed only in IE8
There are a couple of things that can force IE into QuirksMode the most obvious two are
A Missing, malformed or dated Doctype see the table near the bottom of this page for a comprehensive guide to which doctypes will trigger quirksmode
Anything on the page before the DocType, IE insist on the DocType being the absolute first thing to appear in the file or it assumes no DocType and revers to QuirksMode
Use this meta tag in your page head section...
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
It'll finalized your document mode.

Print japanese with jQuery

I'm trying to print some Japanese to a page dynamically using jQuery, and it display nothing recognizable. I don't know what went wrong, I reduced the code to the most straight-forward, and it doesn't fix it. Or maybe it's just me being thick.
I use:
$('body').append('<p>日本語</p>');
Which should work, right?
And I get:
日本語
Huh?
Have you made sure that your page is set to use the Japanese character set? If not, make sure that your charset is defined in your <head></head> node :
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
In some cases Utf-8 character set would be helpful. Add this in your Head node as below.
<head>
<meta charset="utf-8" />
</head>

Categories

Resources