Codoforum related discussions
[Solved] Clean URL in Polish language

I noticed that safeURL don't work for topics in Polish language, for example:

Zażółć gęślą jaźń

So in /sys/CODOF/Filter.php I changed line:

$str = mb_convert_encoding((string) $str, 'UTF-8', mb_list_encodings());

to this:

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

I always use it in my projects and it works well.
http://sandbox.onlinephpfunctions.com/code/110e68c61166d8e57cba4254dec55e72fcbc3061


But... When I created for test new topic: "Zażółć gęślą jaźń" my safeURL is:

zaz-oacute-l-c-ge-sla-ja-z-n

instead of:

zazolc-gesla-jazn


Why i have a lot of additional "-" ? smile
Do you know how to fix this bug?


This depends of PHP version: http://stackoverflow.com/a/38709208


Titles in Polish are broken in database:

57cd5e263f9b2.png

ó is replaced by &oacute ; smile

I noticed that safeURL don't work for topics in Polish language, for example: > Zażółć gęślą jaźń So in **/sys/CODOF/Filter.php** I changed line: ```` $str = mb_convert_encoding((string) $str, 'UTF-8', mb_list_encodings()); ```` to this: ``` $str = iconv("UTF-8", "UTF-8//IGNORE", $str); $str = iconv("UTF-8", "ASCII//TRANSLIT", $str); ``` I always use it in my projects and it works well. http://sandbox.onlinephpfunctions.com/code/110e68c61166d8e57cba4254dec55e72fcbc3061 --- But... When I created for test new topic: "**Zażółć gęślą jaźń**" my safeURL is: >zaz-oacute-l-c-ge-sla-ja-z-n instead of: >zazolc-gesla-jazn --- Why i have a lot of additional "-" ? :S Do you know how to fix this bug? ---- This depends of PHP version: http://stackoverflow.com/a/38709208 --- Titles in Polish are broken in database: ![57cd5e263f9b2.png](serve/attachment&path=57cd5e263f9b2.png) ```` ó```` is replaced by ```` &oacute ; ```` :(
edited Sep 7 '16 at 7:37 am

Which version of codoforum are you using ?

We will test those characters.

Which version of codoforum are you using ? We will test those characters.

Which version of codoforum are you using ?

We will test those characters.

Codoforum v3.6

>Which version of codoforum are you using ? >We will test those characters. Codoforum v3.6
edited Sep 6 '16 at 7:18 pm

Here is a working demo: http://sandbox.onlinephpfunctions.com/code/3ca9951ddfe725703235f0472a754b9fe4a9d7fd

$str = 'Zażółć gęślą jaźń';
    $a = array('/ą/', '/ż/', '/ź/', '/ę/', '/ć/', '/ń/', '/ó/', '/ł/', '/ś/', '/Ą/', '/Ż/', '/Ź/', '/Ę/', '/Ć/', '/Ń/', '/Ó/', '/Ł/', '/Ś/');
    $b = array('a', 'z', 'z', 'e', 'c', 'n', 'o', 'l', 's', 'A', 'Z', 'Z', 'E', 'C', 'N', 'O', 'L', 'S');
    $str = preg_replace( $a, $b, $str );
    echo $str;
Here is a working demo: http://sandbox.onlinephpfunctions.com/code/3ca9951ddfe725703235f0472a754b9fe4a9d7fd ```` $str = 'Zażółć gęślą jaźń'; $a = array('/ą/', '/ż/', '/ź/', '/ę/', '/ć/', '/ń/', '/ó/', '/ł/', '/ś/', '/Ą/', '/Ż/', '/Ź/', '/Ę/', '/Ć/', '/Ń/', '/Ó/', '/Ł/', '/Ś/'); $b = array('a', 'z', 'z', 'e', 'c', 'n', 'o', 'l', 's', 'A', 'Z', 'Z', 'E', 'C', 'N', 'O', 'L', 'S'); $str = preg_replace( $a, $b, $str ); echo $str; ````

Is there any htmlentities in topic title when saving title to the database?
I'm trying to find where is function, which changes my title before it is saved to database.

 

ok, so I have solution:

in sys/CODOF/Format.php I commented out line 135 and set htmlspecialchars:

// $mesg = htmlentities($mesg, ENT_NOQUOTES, "UTF-8");

 
 
 
This is ok for me:

    public static function title($mesg) {

        //$mesg = str_replace("<", "<", $mesg);
        //$mesg = str_replace(">", ">", $mesg);
        $mesg = htmlspecialchars($mesg);
        // $mesg = htmlentities($mesg, ENT_NOQUOTES, "UTF-8");
        return $mesg;
    }

57cf0394532af.png

 
 
In next step I need to set 'transliterate' to true.

 
In sys/CODOF/Filter.php line 36:

'transliterate' => true,

In the end I changed line:

    $str = mb_convert_encoding((string) $str, 'UTF-8', mb_list_encodings());

to:

  //$str = mb_convert_encoding((string) $str, 'UTF-8', mb_list_encodings());
    $str = mb_convert_encoding((string) html_entity_decode($str), 'UTF-8', mb_list_encodings());

Result:
57cf0778399fa.png

 smile

Regards! smile

Is there any htmlentities in topic title when saving title to the database? I&#039;m trying to find where is function, which changes my title before it is saved to database. &amp;nbsp; --- **ok, so I have solution**: in ````sys/CODOF/Format.php```` I commented out line **135** and set htmlspecialchars: ``` // $mesg = htmlentities($mesg, ENT_NOQUOTES, &quot;UTF-8&quot;); ``` &amp;nbsp; &amp;nbsp; &amp;nbsp; This is ok for me: ``` public static function title($mesg) { //$mesg = str_replace(&quot;&lt;&quot;, &quot;&lt;&quot;, $mesg); //$mesg = str_replace(&quot;&gt;&quot;, &quot;&gt;&quot;, $mesg); $mesg = htmlspecialchars($mesg); // $mesg = htmlentities($mesg, ENT_NOQUOTES, &quot;UTF-8&quot;); return $mesg; } ``` ![57cf0394532af.png](serve/attachment&amp;path=57cf0394532af.png) &amp;nbsp; &amp;nbsp; In next step I need to set _&#039;transliterate&#039;_ to **true**.  &amp;nbsp; In ```sys/CODOF/Filter.php``` **line 36**: ```` &#039;transliterate&#039; =&gt; true, ````   In the end I changed line: ```` $str = mb_convert_encoding((string) $str, &#039;UTF-8&#039;, mb_list_encodings()); ````   to: ``` //$str = mb_convert_encoding((string) $str, &#039;UTF-8&#039;, mb_list_encodings()); $str = mb_convert_encoding((string) html_entity_decode($str), &#039;UTF-8&#039;, mb_list_encodings()); ```   --- Result: ![57cf0778399fa.png](serve/attachment&amp;path=57cf0778399fa.png) :)         Regards! 8)
edited Sep 6 '16 at 7:48 pm

I don't know why this problem is repeating again because we had already fixed accented characters.

Thankyou for sharing the solution.

I don&#039;t know why this problem is repeating again because we had already fixed accented characters. Thankyou for sharing the solution.
500
5
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft