|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Shoud this patch apply to the next stable smarty release? |
Of course! |
|
0% |
[ 0 ] |
maybe someday |
|
0% |
[ 0 ] |
Not at all! |
|
0% |
[ 0 ] |
|
Total Votes : 0 |
|
Author |
Message |
adamx Smarty n00b
Joined: 19 Nov 2004 Posts: 1
|
Posted: Fri Nov 19, 2004 10:24 pm Post subject: utf8 compatible mailto |
|
|
I've made some small changes to the mailto function, so now it won't ruin the higher utf8 charcters in the text. It'll also preserve the &something; characters.
The old part was:
Code: |
< $text_encode = '';
< for ($x=0; $x < strlen($text); $x++) {
< $text_encode .= '' . bin2hex($text[$x]).';';
< }
|
And the changed version is:
Code: |
> $text_encode = '';
> $skip = false;
> for ($x=0; $x < strlen($text); $x++) {
> if($skip){$text_encode .= $text[$x]; if($text[$x] == ';'){$skip=false;}}
> elseif($text[$x] == '&'){$text_encode .= $text[$x];$skip = true;}
> elseif($smarty->get_template_vars('utf8') && ((ord($text[$x]) & 0x80) == 0x80)){//if utf8 and is extended character
> $text_encode .= $text[$x];
> } else {
> $text_encode .= '' . bin2hex($text[$x]).';';
> }
> }
>
|
It takes up the encode from wheader the 'uft8' variable is assigned true to the template. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|