⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

grocery crud JS parser problem with russian letters

grocery crud JS parser russian letters

  • Please log in to reply
1 reply to this topic

#1 Mans



  • Members
  • Pip
  • 2 posts

Posted 12 October 2017 - 02:14 PM

Good afternoon!
I'm very sorry for the bad translation from Google.
Please help me solve the problem.
I just started using grocery crud.
Version: grocery crud enterprise v2.3.5 without composer
DB and Tables Collation: utf8 - default collation
Charset: utf8
Faced the following problem, on small tables everything works well, but with some I have problems.
When I try to work with a problem table, I get an error in the modal window:
"We can't process the response of the server. This is all we know about it:
Error:SyntaxError: Unexpected end of JSON input"
Having removed almost all the data from the database table, the error was gone, everything worked, so I came to the conclusion that the problem is in the data table.
Gradually deleting data, line by line, column by column, I determined the problem data.
In my table, I found two data fields, one type VARCHAR (100), the second type LONGTEXT, both fields contained the same text: 'Тепогаева Светлана Владимировна' (without quotes).
I have identified several options when there is no error and when there is an error, but I did not find the law, as I could not solve the problem:
'Тепогаева Светлана Владимировна' - ERROR
'Тепогаева_Светлана_Владимировна' - ERROR
'Тепогаева/Светлана/Владимировна' - ERROR
'ТепогаеваСветланаВладимировна' - ERROR
'Тепогаева Светлана Владими' - WORKS (26 characters, excluding spaces)
'Тепогаева СветланаВладимировна' - WORKS
'Тепогаева_СветланаВладимировна' - WORKS
'Тепогаева/СветланаВладимировна' - WORKS
'Тепогаева Светлана  Владимировна' - WORKS (2 spaces between 2 and 3 words)
'Тепогаева  Светлана  Владимировна' - ERROR (2 spaces between all words)
'123Тепогаева Светлана Владимировна' - WORKS
'Тепогаева Светлана В_abc_ладимировна' - WORKS
'Тепогаева_abc Светлана Владимировна' - ERROR
'Тепогаева Светлана Владимировна абв' - ERROR
'Тепогаева Светлана Владимировна abc' - ERROR
'Тепогаева Светлана Владимировнаabc' - ERROR
'Тепогаева Владимировна Светлана' - ERROR
'Тепогаева Светлана В_абв_ладимировна' - ERROR
'Тепогаеваfff Светлана Владимировна' - WORKS
If I add any number of digits to the string, then everything works. Also works if I add Latin characters. With Russian letters, the problem is if their number is more than 26 characters and they are separated by delimiters.

I just can not determine the relationship, please help me solve the problem. I think the problem is somewhere in JS.

Attached Thumbnails

  • Снимок1.JPG

#2 Mans



  • Members
  • Pip
  • 2 posts

Posted 14 October 2017 - 02:46 PM

Due to the fact that the support service is ready to answer me only in a week, I had to look for the solution of the problem myself.
I found the cause of the problem!
Line: 222
$columnValue = $char_limiter > 0 && (strlen($columnValue) > $char_limiter) ? substr($columnValue, 0 , $char_limiter - 1) . '...' : $columnValue;
This code shortens the column text to the desired length. As a result of this code, the string
'Тепогаева Светлана Владимировна'
turns into
'Тепогаева Светлана Владим�...'
Because of this, an error occurs!

The problem is related to the incorrect operation of method substr() and Russian symbols.

Replace string
$columnValue = $char_limiter > 0 && (strlen($columnValue) > $char_limiter) ? substr($columnValue, 0 , $char_limiter - 1) . '...' : $columnValue;
$columnValue = $char_limiter > 0 && (strlen($columnValue) > $char_limiter) ? mb_substr($columnValue, 0 , $char_limiter - 1,'UTF-8') . '...' : $columnValue;
Now as a result of new code, the string
'Тепогаева Светлана Владимировна'
turns into
'Тепогаева Светлана Владим...'


The error does not appear, the problem is solved.

Thanks to all!

Also tagged with one or more of these keywords: grocery crud, JS, parser, russian, letters

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users