wet-boew / wet-boew

Web Experience Toolkit (WET): Open source code library for building innovative websites that are accessible, usable, interoperable, mobile-friendly and multilingual. This collaborative open source project is led by the Government of Canada.

Home Page:https://wet-boew.github.io/wet-boew/index-en.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Datatable (serverSide) French characters when searching

zomby22 opened this issue · comments

Anyone have a suggestion, a code, related to searching any words or phrases that includes French Characters. I have a datatable using serverside (my ajax file is a json ASP page). I can search for anything including apostrophes but the rows clears when entering any French characters and I wonder why the search does not support it. What else can be included to make it work, is this doable without any additional plugins.

table:
data-wb-tables='{ "ordering" : true, "processing": true, "serverSide": true, "ajax": { "url": "activity_ajaxdata.asp", "type": "POST", "async": false },

json ASP:
`strSearch = server.HTMLEncode(lcase(trim(Request("search[value]"))))

if strSearch <> "" then
strWhere = strWhere & " and (dbactivity.id::text LIKE '%" & JSONEscape(sqlSingleQuote(strSearch)) & "%' OR "
strWhere = strWhere & " lower(dbactivity.dbtitle::text) SIMILAR TO '%" & JSONEscape(sqlSingleQuote(strSearch)) & "%')"
end if`

Maybe this will help:
#9638 (comment)

You may have to add this to data-wb-tables:

"language": {
        "url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json"
    },

Or maybe you need this: https://datatables.net/plug-ins/filtering/type-based/diacritics-neutralise

thanks for the help. couldnt get it working, trying to solved this part (which dependencies is missing?)

accent-neutralise.js:309 Uncaught TypeError: Cannot read properties of undefined (reading 'ext')
    at accent-neutralise.js:309:11
    at accent-neutralise.js:42:3
    at accent-neutralise.js:44:2

DataTable.**ext.type.search.allowDiacritics**

I'd verify that your browser is actually sending the correct data in the POST request.
Then on the server side, your going to have to debug and verify it is the same data in the "search[value]".

I'm using PHP and works without any extra plugins. I would guess that your json ASP server side code is not correct.

Wet has diacritics built in, I wonder if the character é and others are being converted where your search doesn't find them?
I don't think this is a WET issue.

i did a test with my server side page - when I enter the word "français" it appears with unicode character. The page is using UTF-8, but my json results is in unicode format. I try to use a function to decode the characters, but the results remains the same.

{"draw": 0,"recordsTotal":1,"recordsFiltered": 1,"data": [["123","fran\u00E7aise

issue is with HTMLEncode (cant use this with unicode characters)

Got it working:

  1. I remove server.HTMLEncode
  2. using SIMILAR TO instead of LIKE in my Query (SIMILAR TO '%" & JSONEscape(sqlSingleQuote(strSearch)) & "%')
    yea LIKE was not working when I search "présentation" change it back to SIMILAR TO and it worked.