Why is %E2%80%8F being added to my Youtube embed code?


I have a bunch of videos on Youtube which I embed using the same code. All of the videos worked fine until I uploaded the last one. Every time I now execute the code, %E2%80%8F is appended to the last uploaded video, unless I specifically ask for a substring(0,11); note that without this hack, the code still works fine for all of my other uploaded videos. And though the code now works with my hack, it would be great to understand why this could be happening.

My HTML markup looks like this:

<li><a href="#" class="help_video" id="oG-M25hnDII‏">sidebars</a></li>

My javascript/jquery looks like this:

function openNewWindow(youtube_link) {
var youtube_link = youtube_link.toString();

youtube_link = youtube_link.substring(0,11);
 popupWin = window.open('/videos/help.php?youtube_link='+youtube_link,
 'open_window',
 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=800, height=440, left=0, top=0')
 }

$(".help_video").click(function(){
openNewWindow($(this).attr('id'));
return false;
});
 });

Then, my associated help.php has the following code:

<iframe width="756" height="426" src="//www.youtube.com/embed/<?php echo $_GET['youtube_link'];?>?rel=0&vq=hd720" frameborder="0" allowfullscreen></iframe>

Thanks!


Answers:


The link includes the right-to left mark UTF8 character

Take a look here: http://en.wikipedia.org/wiki/Right-to-left_mark

This is a non-printing character, so you won't see it on screen, but your editor sneaked it in.

Try

  • using another editor to write again this portion of code
  • settting up your code editor to display special characters (tabs, newlines, etc). This way you'll be able to see and delete the rtl mark