Jump to content
rupruprup

German Special Chars (Umlaute) in search Result

Recommended Posts

I am setting up a new Shop that is currently on PHOENIX 1.0.5.8

language is German only de_DE.UTF-8 , Database is utf8_unicode_ci

when I search for "Löffel" I get no results but "Loffel" displays what I need, the same happens with all other special chars

the search core is unmodified

I remember that I had a similar problem in 2.3.4 years ago but I do not remember what I did ☹️

Share this post


Link to post
Share on other sites

This suggests that perhaps the umlauted character is getting garbled on the way to the database. If the database is encoded utf-8 and the web page is also, then it's possible that the mysql server daemon is not defaulting to utf-8 for everything

You could try running the query

SET NAMES utf8

before the search query.

You might get other problems though. If this theory were correct then you would have to be running on a new server but against a database that was originally populated somewhere else as I would expect data saved on this server to be garbled too. If it's under your control you might need to change the server's mysql startup configuration.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites
38 minutes ago, BrockleyJohn said:

not defaulting to utf-8 for everything

thank you John, but I went a bit deeper

the special chars problem starts when the function tep_parse_search_string ... is called

bypassing the function with a single keyword only works without issues

@burt this might be Phoenix issue ??

 

Share this post


Link to post
Share on other sites
Posted (edited)

Maybe try changing

    $search_str = trim(strtolower($search_str));

to

    $search_str = trim(mb_strtolower($search_str));

If that fixes it, we could consider adding that to core.  But I first want to know if it fixes the problem without creating other problems. 

If it doesn't go to core, an alternative would be to set the locale properly.  From https://www.php.net/manual/en/function.strtolower.php

Quote

Note that 'alphabetic' is determined by the current locale. This means that e.g. in the default "C" locale, characters such as umlaut-A (Ä) will not be converted.

 

Edited by ecartz

Always back up before making changes.

Share this post


Link to post
Share on other sites

thank you Matt , that's it - it is fixed and does not seem to create any other problem

6 hours ago, ecartz said:

Maybe try changing


    $search_str = trim(strtolower($search_str));

to


    $search_str = trim(mb_strtolower($search_str));

 

Share this post


Link to post
Share on other sites
2 hours ago, rupruprup said:

does not seem to create any other problem

I looked into this more.  The problem it creates is that it adds a dependency on the mbstring extension which is not always installed.  There also might be encoding problems if the default encoding is different from the encoding of the string.  Perhaps

          if ( (defined('MODULE_HEADER_TAGS_PRODUCT_META_KEYWORDS_STATUS')) && (MODULE_HEADER_TAGS_PRODUCT_META_KEYWORDS_STATUS != 'Meta') ) {
            $where_str .= "pd.products_seo_keywords LIKE '%" . tep_db_input($keyword) . "%' OR ";
          }
          $where_str .= "pd.products_name LIKE '%" . tep_db_input($keyword) . "%' OR p.products_model LIKE '%" . tep_db_input($keyword) . "%' OR m.manufacturers_name LIKE '%" . tep_db_input($keyword) . "%'";
          if (isset($_GET['search_in_description']) && ($_GET['search_in_description'] == '1')) $where_str .= " OR pd.products_description LIKE '%" . tep_db_input($keyword) . "%'";

to

          if ( (defined('MODULE_HEADER_TAGS_PRODUCT_META_KEYWORDS_STATUS')) && (MODULE_HEADER_TAGS_PRODUCT_META_KEYWORDS_STATUS != 'Meta') ) {
            $where_str .= "pd.products_seo_keywords LIKE LOWER('%" . tep_db_input($keyword) . "%') OR ";
          }
          $where_str .= "pd.products_name LIKE LOWER('%" . tep_db_input($keyword) . "%') OR p.products_model LIKE LOWER('%" . tep_db_input($keyword) . "%') OR m.manufacturers_name LIKE LOWER('%" . tep_db_input($keyword) . "%')";
          if (isset($_GET['search_in_description']) && ($_GET['search_in_description'] == '1')) $where_str .= " OR pd.products_description LIKE LOWER('%" . tep_db_input($keyword) . "%')";

in advanced_search_result.php and remove the strtolower from tep_parse_search_string. 

    $search_str = trim($search_str);

 


Always back up before making changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×