<div dir="ltr">Some background.<div>I am trying to update the SearchCloud recipe.</div><div><br></div><div>The recipe grabs the q parameter of a search action.</div><div><br></div><div>I want it to </div><div>* make the search terms insensitive</div><div>* handle characters with diacritics.</div><div><br></div><div>Here is some debug output</div><div><br></div><div><font face="monospace" size="1">2022-10-19 21:26:01 </font></div><div><font face="monospace" size="1"><b>q</b>="S&#256;ÉÎÖ&#364;-à&#281;iø&#369;d" </font></div><div><font face="monospace" size="1"><b>$SCrq</b>="S&#256;ÉÎÖ&#364;-à&#281;iø&#369;d" </font></div><div><font face="monospace" size="1"><b>tkey1</b>="SÄ€ÉÎÖŬ-àÄ™iøűd" </font></div><div><font face="monospace" size="1"><b>tkey2</b>="sÄ ???Å­-?Ä™i?űd" </font></div><div><font face="monospace" size="1"><b>tkey3</b>="sÄ ???Å­-?Ä™i?űd"</font><br></div><div><font face="monospace" size="1"><br></font></div>Generated from debug code<div><font face="monospace" size="1">      $convmap = array (0x80, 0xffff);<br>      $q     = strval(<font color="#9900ff">$_REQUEST['q']</font>); # get search term<br>      $SCrq  = trim (\stripmagic($q));<br>      $tkey1 = <font color="#274e13"><b>html_entity_decode</b></font>($SCrq); # remove html entities to allow lower case conversion<br>      $tkey2 = <font color="#274e13"><b>mb_strtolower</b></font>($tkey1); # convert to lower case<br>      $tkey3 = <font color="#274e13"><b>mb_encode_numericentity</b></font> ($tkey2, $convmap); # convert non-ascii to htmlentities<br>      $fwritestatus = fwrite($logfilehandle, $logfiletime <br>      . 'q="' . $q <br>      . '" $SCrq="' . $SCrq <br>      . '" tkey1="' . $tkey1 <br>      . '" tkey2="' . $tkey2 <br>      . '" tkey3="' . $tkey3 . '"' <br></font><br></div><div>As you can see in the debug output it seems to fall apart at tkey2.</div><div>I'd welcome more suggestions</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 18 Oct 2022 at 23:39, Petko Yotov <<a href="mailto:5ko@5ko.fr">5ko@5ko.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You may be able to use:<br>
<br>
   $entity = mb_convert_encoding($decoded, 'HTML');<br>
<br>
<br>
You may or may not need to specify a $from_encoding argument. From the <br>
documentation it seems before PHP 8.0 $from_encoding was required. <br>
Documentation:<br>
<br>
   <a href="https://php.net/mb_convert_encoding" rel="noreferrer" target="_blank">https://php.net/mb_convert_encoding</a><br>
<br>
Petko<br>
<br>
-- <br>
If you upgrade :  <a href="https://www.pmwiki.org/Upgrades" rel="noreferrer" target="_blank">https://www.pmwiki.org/Upgrades</a><br>
<br>
<br>
On 18/10/2022 12:17, Simon wrote:<br>
> Again, thanks heaps for answering these newbie questions, that works.<br>
> What I think I have found is that while html_entity_decode('&#274;')<br>
> gives "Ē"<br>
> htmlentities ("Ē") doesn't convert Ē back to  &#274;<br>
> <br>
> Simon<br>
> <br>
> On Tue, 18 Oct 2022 at 19:18, Petko Yotov <<a href="mailto:5ko@5ko.fr" target="_blank">5ko@5ko.fr</a>> wrote:<br>
> <br>
>> You can use mb_strtolower():<br>
>> <br>
>> <a href="https://php.net/mb_strtolower" rel="noreferrer" target="_blank">https://php.net/mb_strtolower</a><br>
>> <br>
>> Here is an example from the PHP interactive shell:<br>
>> <br>
>> php > $str = "e.g. Ā to ā, Ê to ê, Į to į, etc";<br>
>> php > print_r(mb_strtolower($str));<br>
>> e.g. ā to ā, ê to ê, į to į, etc<br>
>> php > print_r(mb_strtoupper($str));<br>
>> E.G. Ā TO Ā, Ê TO Ê, Į TO Į, ETC<br>
>> <br>
>> Petko<br>
>> <br>
>> --<br>
>> If you upgrade :  <a href="https://www.pmwiki.org/Upgrades" rel="noreferrer" target="_blank">https://www.pmwiki.org/Upgrades</a><br>
>> <br>
>> On 18/10/2022 06:46, Simon wrote:<br>
>>> Can anyone suggest a means of converting diacritic [1]characters<br>
>> to<br>
>>> lower case,<br>
>>> e.g. Ā to ā, Ê to ê, Į to į, etc<br>
>>> other than creating a translation table?<br>
>>> <br>
>>> thanks<br>
>>> <br>
>>> Simon<br>
>>> <br>
>>> <br>
>>> <br>
>>> Links:<br>
>>> ------<br>
>>> [1] <a href="https://en.wikipedia.org/wiki/Diacritic" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Diacritic</a><br>
>>> _______________________________________________<br>
>>> pmwiki-devel mailing list<br>
>>> <a href="mailto:pmwiki-devel@pmichaud.com" target="_blank">pmwiki-devel@pmichaud.com</a><br>
>>> <a href="http://www.pmichaud.com/mailman/listinfo/pmwiki-devel" rel="noreferrer" target="_blank">http://www.pmichaud.com/mailman/listinfo/pmwiki-devel</a><br>
</blockquote></div>