How to solve the apostrophe problem in node title? (&#039; -> ') Node title includes ' (apostrophe) and it appears normal while viewing the node. But in page source it appears as &amp;#039;.

And for the same reason when I want to share this node on Twitter with some custom code put into node.tpl.php (&lt;?php print urlencode($title) ?&gt;) it also shows the ' as &amp;#039;.

How to solve this problem?
Your issue seems similar to what's written in issues such as this or this.

The solution appears to be to use decode_entities, e.g. something like this:

$node-&gt;title = decode_entities($node-&gt;title);