• Resolved mikehaceman

    (@mikehaceman)


    As I mentioned in my previous support post – “search functionality” works while using e.g. Chinese characters.

    Unfortunately when in admin dashboard -> Popular searches and Daily Popular searches – searched characters are not recognised and displayed as “?? ??”

    Also “Popular searches” widget displays “?? ??”. And it is reflected in the same fashion using “heatmap”.

    Is it possible to fix this?

    Thanks!

    https://ww.wp.xz.cn/plugins/better-search/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Ajay

    (@ajay)

    I’m not really sure what the solution to this could be. Do the search results work fine and display the characters better?

    Thread Starter mikehaceman

    (@mikehaceman)

    So here is the scenario:

    I do not have any translation plugins. It is simple wordpress website with articles/menu etc in Chinese. I tried both “English version” and “Chinense Version” of wordpress – situation is the same.

    If you type in “wordpress generic search” e.g. “越久” it will not display anything. I tried other custom search engines for wordpress and they heavily rely on classic abcd with focus on entire words and spaces between them.

    In Asian languages like Chinese there is no spaces between words so the search has to be specifically based on characters only. The logic and meaning – is not really needed.

    So your plugin i think is the only one that I am aware of, that works on characters not words except google search engine.

    ——————————-The problem ———————————

    If I search for “越久” it will display the results accordingly. But in the “heath map”, most common searches widget and admin dashboard “daily searches” this word will not be recognized. Simply Chinese characters will be replaced by “?? ??”. Screen shot:
    https://s3.postimg.org/eq24bddhf/image.jpg

    So Im guessing – not a real coder here 😉 that when search is being executed it is being called in different way than displaying it in e.g. Most common searches widget.

    You could really take this search engine to next level if it could work flawlessly with Chinese characters – another market to conquer for you 😉

    Thanks!

    Plugin Author Ajay

    (@ajay)

    That’s clear. I think it is one of the functions that the heat map function uses that must be breaking this functionality.

    Potetentially this line in the heatmap

    $textsearchvar = esc_attr( $result->searchvar );

    Maybe try removing the esc_attr function and also replying by esc_html

    It’s difficult for me to figure it out given I don’t speak, read or write any of the Asian script languages

    Thread Starter mikehaceman

    (@mikehaceman)

    Sure no problem, I can test any idea you have 😉

    As for $textsearchvar = esc_attr( $result->searchvar ); ->
    $textsearchvar = esc_html( $result->searchvar );

    Didnt make any difference 🙁

    Thread Starter mikehaceman

    (@mikehaceman)

    Also, i saw some solutions to Chinese characters like utf-8 in wp-admin.php. This is not a solution to this problem – every other plugin, page, post, widget or admin area works with Chinese characters. Only “widgets” of this plugin are not displayed correctly.

    I googled this: http://stackoverflow.com/questions/13496271/how-to-properly-display-chinese-characters-in-php

    You think it might be some solution?

    Thread Starter mikehaceman

    (@mikehaceman)

    Ok i think i found solution but i dont understand 😉

    Here is someone who had similar problem and found fix:

    http://stackoverflow.com/questions/29322108/get-chinese-characters-from-mysql

    Let me know what you think 😉

    Plugin Author Ajay

    (@ajay)

    That’s interesting. is the better search tables set to utf8? This is the character encoding settings / collation. You can check this when browsing the database in phpMyAdmin or Adminer

    It might be something like: utf8_general_ci

    What would also be useful is if you browse the wp_bsearch folder (carefully) to see what is stored in there. It could be the case that the searches are not being saved correctly.

    Thread Starter mikehaceman

    (@mikehaceman)

    From the link above i did this command:

    echo mb_detect_encoding ( $text );

    And it showed ASCII on the page.

    phpAdmin shows: MySQL charset: UTF-8 Unicode (utf8)
    MySQL connection collation: utf8_general_ci

    I went to wp_bsearch and here is something different?

    Field: searchvar
    Type: varchar(100)
    Collation: latin1_swedish_ci
    Format: dynamic

    Seems like the table is setup wrong?
    wp_bsearch_daily has the same settings 🙁

    Plugin Author Ajay

    (@ajay)

    Please see how you can change these. Unfortunately, I think all old characters might just stay the same.

    https://www.a2hosting.com/kb/cpanel/cpanel-database-features/changing-the-mysql-collation-settings-in-phpmyadmin

    Thread Starter mikehaceman

    (@mikehaceman)

    Hi i followed this link and changed tables wp_bsearch and wp_bsearch_daily from latin1_swedish_ci to utf8_unicode_ci

    Now new searches are not being saved in the database = results are displayed on the page but is not being reflected in heath map or daily searches widget … not even with “????”

    So i guess changing Collation in Settings (via phpAdmin) of the table didnt make difference here? How to make a difference?

    Also why your plugin tables are being saved in latin1_swedish_ci not in generic WP utf8_general_ci ? Maybe that needs to be updated in new release also?

    Thanks

    Thread Starter mikehaceman

    (@mikehaceman)

    Ok i got it!!!

    1. I had “Enable tracking for admins” ticked off … sorry my bad …
    2. I had to change in both tables searchvar from latin1_swedish_ci to utf8_general_ci

    not only via “Operations” in phpAdmin but also for each table via edit on “Structure”.

    I hope that this will stay that way (even after new release)? Could you make sure that the tables in your plugin will from now on be set to utf8_general_ci “??

    If all implemented – you can advertise this plugin as Chinese characters friendly 😉

    Plugin Author Ajay

    (@ajay)

    I need to relook at the table generation cofe and make sure it is always utf8 from now on. But that should be fine

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Asian characters – almost there?’ is closed to new replies.