solved Replacing special Latin characters in friendly URLs issue

pch
@pch
10 years ago
328 posts
Hello,

JR has an issue with replacing special latin characters in the friendly URLs.

Example: A profile with a French name like: François Hollande will get an url like this:

site.com/franois-hollande

Instead of:

site.com/francois-hollande

Special Latin characters (French, Spanish, Portuguese) are not been replaced. They are just being ignored/removed from the friendly URL url.

How to get it fixed in JR?

I have already used many other script on the internet that managed to fixed this issue with a String replace function.

Example:

$string = str_replace
       
array('á', 'à', 'ä', 'â', 'ª', 'Á', 'À', 'Â', 'Ä'),
array('a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A'),

array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ê', 'Ë'),
array('e', 'e', 'e', 'e', 'E', 'E', 'E', 'E'),

array('í', 'ì', 'ï', 'î', 'Í', 'Ì', 'Ï', 'Î'),
array('i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'),

array('ó', 'ò', 'ö', 'ô', 'Ó', 'Ò', 'Ö', 'Ô'),
array('o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'),

array('ú', 'ù', 'ü', 'û', 'Ú', 'Ù', 'Û', 'Ü'),
array('u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'),
        
array('ñ', 'Ñ', 'ç', 'Ç'),
array('n', 'N', 'c', 'C',),
        
array("\\", "¨", "º", "-", "~",
      "#", "@", "|", "!", "\"",
      "·", "$", "%", "&", "/",
      "(", ")", "?", "'", "¡",
      "¿", "[", "^", "`", "]",
      "+", "}", "{", "¨", "´",
      ">", "< ", ";", ",", ":",
      "."),


or Maybe like this:

array('Š'=>'S','š'=>'s','Ð'=>'Dj','ð'=>'dj','Ž'=>'Z','ž'=>'z','?'=>'C',
'?'=>'c','?'=>'C','?'=>'c','À'=>'A','Á'=>'A','Â'=>'A','Ã'=>'A','Ä'=>'A',
'Å'=>'A','Æ'=>'A','Ç'=>'C','È'=>'E','É'=>'E','Ê'=>'E','Ë'=>'E','Ì'=>'I',
'Í'=>'I','Î'=>'I','Ï'=>'I','Ñ'=>'N','Ò'=>'O','Ó'=>'O','Ô'=>'O','Õ'=>'O',
'Ö'=>'O','Ø'=>'O','Ù'=>'U','Ú'=>'U','Û'=>'U','Ü'=>'U','Ý'=>'Y','Þ'=>'B',
'ß'=>'Ss','à'=>'a','á'=>'a','â'=>'a','ã'=>'a','ä'=>'a','å'=>'a','æ'=>'a'
,'ç'=>'c','è'=>'e','é'=>'e','ê'=>'e','ë'=>'e','ì'=>'i','í'=>'i','î'=>'i',
'ï'=>'i','ð'=>'o','ñ'=>'n','ò'=>'o','ó'=>'o','ô'=>'o','õ'=>'o','ö'=>'o',
'ø'=>'o','ù'=>'u','ú'=>'u','û'=>'u','ý'=>'y','ý'=>'y','þ'=>'b','ÿ'=>'y',
'?'=>'R','?'=>'r',);

I am not giving a lesson. I am not a coder. I have just copied this stuff from the internet and pasted it here for illustration purposes only (example).


Thanks
updated by @pch: 02/18/16 06:06:39PM
brian
@brian
10 years ago
10,149 posts
Jamroom uses iconv which should handle this - do you have iconv installed in your PHP?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
10 years ago
328 posts
Well, how to check if it is installed on my server? I run a VPS.
brian
@brian
10 years ago
10,149 posts
I've just tested here and it is working for me:

http://local.jamroom.net/Jamroom5/francois-hollande

So check that iconv() is installed in your PHP.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
10 years ago
10,149 posts
pch:
Well, how to check if it is installed on my server? I run a VPS.

ACP -> System -> System Check. Click on "phpinfo" next to your PHP version. Look for the "iconv" section.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
10 years ago
328 posts
I have this:

iconv

iconv support enabled
iconv implementation glibc
iconv library version 2.12

Directive Local Value Master Value
iconv.input_encoding ISO-8859-1 ISO-8859-1
iconv.internal_encoding ISO-8859-1 ISO-8859-1
iconv.output_encoding ISO-8859-1 ISO-8859-1
brian
@brian
10 years ago
10,149 posts
What version of PHP are you using?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
10 years ago
328 posts
5.4.45
brian
@brian
10 years ago
10,149 posts
I think the issue here is that your iconv has it's output encoding set to ISO-8859-1 instead of UTF8. I have a PHP 5.4 install here that is setup the same as yours and it removes the character as well. On my PHP 5.6 install there is no issue since those options have been removed.

Looks like we can set the output formatting via an ini_set() for older PHP installs - I'll work on that for 5.3.0b4 and that should hopefully fix it on your install.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 11/13/15 01:57:33PM
pch
@pch
10 years ago
328 posts
Thanks Brian. What about if I ask my Web host to set my iconv output encoding to UTF8 instead of ISO-8859-1? Can it be done? Will it work for me? or What about if I ask them to upgrade my PHP to 5.6, will it fix this issue?

Thanks
brian
@brian
10 years ago
10,149 posts
pch:
Thanks Brian. What about if I ask my Web host to set my iconv output encoding to UTF8 instead of ISO-8859-1? Can it be done? Will it work for me? or What about if I ask them to upgrade my PHP to 5.6, will it fix this issue?

Thanks

Just go to ACP -> Core -> Marketplace -> Reload Modules and Skins and reload Core 5.3.0b3 - let me know if that fixes it for you.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
10 years ago
328 posts
I am still running the core 5.2.41. I didn't installed the version 5.3.0b3 because I saw it is still in Beta and I was waiting for a release candidate. I will upgrade the core version and let you know.
pch
@pch
10 years ago
328 posts
I have just upgraded to 5.3.0b3 and upgrade all the modules. In ACP -> Core -> Marketplace -> Reload Modules and Skins and I have reloaded Core 5.3.0b3. Then I have check the integrity. That didn't fix the Special Latin Characters issue.
brian
@brian
10 years ago
10,149 posts
That should have worked - are you creating a NEW profile? It's not going to fix one that was already created. If it still does not work, I would need to get access (FTP) to your server so I can find out why.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
10 years ago
328 posts
Well, I was trying to fix one that was already created . How to fix it?
pch
@pch
10 years ago
328 posts
Hi Brian. Thanks a lot. It works even with the one already created. What I did is: I have renamed the account user and its profile to something else. Then renamed it back to the same original name with the special characters. The issue was fixed. The friendly URL was properly created and special latin characters were replaced.

Thanks for the support.
brian
@brian
10 years ago
10,149 posts
Glad to hear that - thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags