Sebastian
Sebastian

Reputation: 415

Invisible leading characters in URL

I'm trying, using MySQL, to flag obvious non URLs among a column of what should be URL's. I'm taking the first seven characters of the URL name and seeing if they come out to 'http://' or 'https:/'. One URL, however, instead returns 'http:' like so:

SELECT SUBSTR(my_URL,1,7) FROM my_URL_table

Returns: 'http:' - apparently five characters, not seven as expected. The offending, real life URL is:

http://www.wsmv.com/story/34609714/f...s-parade-crash

It's as if there were two extra characters, at the beginning of the URL, that are both invisible and take up no space. (Dark matter characters?). Indeed, if I run the INSTR function to see at which position 'http://' starts in the URL, MySQL returns position 3, like so:

SELECT INSTR(my_URL,'http://') FROM my_URL_table

Returns: 3 and not the first position. I tried that SELECT with the addition of a TRIM(my_URL) function, but the TRIM changed nothing.

The URL was put into the table using an INSERT VALUES command that I wrote in Notepad++ and ran in phpMyAdmin.

Can anyone think what those mystery characters might be? Advice on how to deal with them?

Thanks for any help!

Upvotes: 2

Views: 244

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269963

I don't know, but MySQL can tell you:

select ord(left(my_url, 1)), ord(substr(my_url, 2, 1))
. . .

The ord() function will tell you the numeric equivalent of the character, as explained in the documentation.

Upvotes: 2

Related Questions