Welcome Guest, Not a member yet? Register   Sign In
url helper special characters
#1

[eluser]Perkin5[/eluser]
I am using the url helper safe_mailto function and have this:

Code:
echo safe_mailto('[email protected]', 'Email »');

I'm expecting the Ampersand raquo; code to render as a right angle quote but it is displayed literally. I have tried the equivalent Ampersand #187; but the result is similar.

Can anyone explain why and how to fix?
#2

[eluser]Aken[/eluser]
Take a look at the helper code, and your source code. It "encodes" on a per-character basis, into JS ordinal numbers. So you're better off putting the character itself in (if it has an ordinal equivalent, which it should - I'm not 100% familiar with the process).
#3

[eluser]Perkin5[/eluser]
Don't think I understand what you mean. A right angle quote cannot be typed as a keyboard character so how else can I indicate it in the code?
#4

[eluser]Perkin5[/eluser]
Come on guys! Someone must have a workaround for this - it's driving me nuts.
#5

[eluser]Aken[/eluser]
As long as you're saving your PHP document as a UTF-8 encoded file (which most should be by default, unless your text editor is weird), then you can copy the character from a special character program on your computer, or from a website, and paste it directly into your code where you want to use it.

That or don't use the quote as part of the link, and leave it next to it (maybe use CSS to make sure it has the same color if that's what you want).
#6

[eluser]Perkin5[/eluser]
I think your last suggestion is the best solution for me - but I still can't understand why it happens. I would have thought that CI simply dumps the characters in the dom as typed and the browser recognizes them as denoting a symbol. Obviously it's not as simple as that.
#7

[eluser]Aken[/eluser]
Look at the actual output in your source code, and you'll see they don't just dump the characters. If that's all it did, there'd be no point to this function. Look at the actual safe_mailto() function code, also. Then you'll see exactly what's going on.
#8

[eluser]Perkin5[/eluser]
Did that - total bafflement! I understand that the destination address is scrambled but why would the link text need to be scrambled?
#9

[eluser]Aken[/eluser]
The point is to obscure the email address so spam bots can't grab it. That needs to be done both for the anchor URL and the actual text, because bots can grab both.
#10

[eluser]Perkin5[/eluser]
OK got that - and I will act accordingly. Many thanks for your time and patience.




Theme © iAndrew 2016 - Forum software by © MyBB