You are here:  » Special characters in URL product page


Special characters in URL product page

Submitted by eriknielsen on Thu, 2019-02-07 10:41 in

Hi David,

I have some trouble with special characters in the product URL:s. Mainly use Swedish products and the letters å ä ö are common. Read the similar post here https://www.pricetapestry.org/node/542 and tried your provided solution - without luck unfortunately. With the provided fix i get a rewrite from å ä ö to ? in the URL. What i want is the following.

å > a
ä > a
ö > o

Any ideas how to modify the solution to fit my needs?

Best regards.

Submitted by support on Thu, 2019-02-07 11:37

Hi and welcome to the forum!

Using the iconv method from node 542 this should be resolved by setting the locale prior to the call to iconv e.g.

    setlocale(LC_CTYPE,"en_US.UTF-8");
    $text = iconv("UTF-8","ASCII//TRANSLIT",$text);

I've updated the replacements for the Price Tapestry installation includes/tapestry.php and plugin pto_common.php in node 542 to include the setlocal() call. After adding the lines re-import all feeds again and that should do the trick...

Cheers,
David.
--
PriceTapestry.com

Submitted by eriknielsen on Thu, 2019-02-07 12:06

Hi,

Thanks David, it worked like a charm.

Best regards.
Erik

Submitted by presbyran on Sun, 2020-04-05 22:09

Hi David

I have followed the steps, but i still having problem with åäö characters.

All åäö becomes "

Example:
kväll -> kv"ll

Same on both PT and WP

Anything i did wrong?

Please help, been trying to solve this a couple of hours now :)

Thanks

Submitted by support on Mon, 2020-04-06 07:27

Hi and welcome to the forum!

I would check whether this is down to source data being ISO-8859-1 rather than UTF-8 encoded - in the replacements to includes/tapestry.php (standalone) and pto_common.php (plugin), for the setlocale() in place of:

     setlocale(LC_CTYPE,"en_US.UTF-8");

...try:

     setlocale(LC_CTYPE,"en_US.ISO-8859-1");

And in place of:

     $text = iconv("UTF-8","ASCII//TRANSLIT",$text);

...try:

     $text = iconv("ISO-8859-1","ASCII//TRANSLIT",$text);

(and re-import)

If still no joy, revert the changes (as UTF-8 is by far the most common encoding) and then if you could perhaps email me (zipped if large) an example feed and product name containing the characters that are not translating as expected I'll check it all through on my test server...

Cheers,
David.
--
PriceTapestry.com