PhpStorm Import data from CSV file to MySQL, Cyrillic problem - php

I have problem with encoding while trying to import data from CSV file to MySQL database in PhpStorm. The CSV file contains Cyrillic symbols. I've read some articles, tried many things, but none of them worked for me.
In my.ini file I changed:
collation_server=utf8_unicode_ci to collation_server=utf8mb4_unicode_ci and
character_set_server=utf8 to character_set_server=utf8mb4
but the result was still the same.
That's my CSV file:
NAME_1,NAME_2,NAME_3
Vladimir,Ivanov,Kaziyski
ИВАН,ПЕТРОВ,ГЕОРГИЕВ
John,Lee,Smith
ПЕТЪР,ЙОРДАНОВ,ПЕТРОВ
In PhpStorm I click right-button on the database which I will import data and then I click:
then I chose the CSV file
and in the Data Preview section everything looks normal, encoding is set to UTF-8
and after that I get this error
Here is the log:
2:1: Data truncation: Incorrect string value: '\xD0\x98\xD0\x92\xD0\x90...' for column `current_db`.`csv_data`.`NAME_1` at row 2
3:1: Data truncation: Incorrect string value: '\xD0\x98\xD0\x92\xD0\x90...' for column `current_db`.`csv_data`.`NAME_1` at row 1
4:1: Data truncation: Incorrect string value: '\xD0\x98\xD0\x92\xD0\x90...' for column `current_db`.`csv_data`.`NAME_1` at row 2
5:1: Data truncation: Incorrect string value: '\xD0\x9F\xD0\x95\xD0\xA2...' for column `current_db`.`csv_data`.`NAME_1` at row 1
I've searched this error and tried almost all solutions, but nothing worked. The problem for sure is Cyrillic. Does anyone with PhpStorm had the same issue and how to fix it?

utf8 vs utf8mb4 does not matter for Cyrillic, only for Emoji and Chinese.
Please provide SHOW CREATE TABLE. I suspect you did not change the CHARACTER SET for the column(s) that will receive the Cyrillic characters.

Related

Incorrect string value: '\xF9'

I'm trying to convert a vBulletin forum in phpBB .. In local everything went well with a sample forum, on the server instead I get this error:
code:
SQL ERROR [ mysqli ]
Incorrect string value: '\xF9' for column 'poll_option_text' at row 1
[1366]
Now, from what I read on the web, it is a coding error .. So I'm trying to change the encoding that column but the result does not change .. I always appears the same mistake ..
Am I doing something wrong?
Should I change the encoding to the database or table ..?

Displaying long ntext field in PHP page has truncated or strange text appended

I have a problem trying to display an ntext MS SQL Server field in my PHP web page.
The field in the database stores an HTML formatted document with all the tags.
Database MS SQL 2012 with collation set to Latin1_General_CI_AS and the field type is ntext
HTML page has an encoding meta tag set to UTF8
<meta charset="UTF-8">
PHP has the following to try to strip out the tags.
$note2 = odbc_result($result, data2);
$note2 = mb_convert_encoding($note2, 'UTF-8', 'Latin1_General_CI_AS');
$note2 = strip_tags($note2, "<br><p>");
echo trim($note2);
I am getting strange and inconsistent results
For example the second half of the actual text is replaced with some other text that can include SQL code or warning messages like this.
functitrto¸Ù 4¬T 4¬T not safe to rely on the system's timezone
settings. Plep! ì«T ì«T .timezone setting, the TÙì èÕì ment variable
oe date_d fault_timezone_set() function. In c àYì Ùì ù 0 Days, 1
Hours, 16 Minsll getting thisøÁ t¬T t¬T st likely misspelled the
timezone identifier. We selected 'Europe/London' for '1.0/DST'
instead0ù¬«T ¬«T É0 ±± Üì L{ ÈNì ~üa´ÐÜì Câ É
I have tried CAST(myntextfield AS TEXT) AS mytextfield but that changed my returned text so that it only returned the second half of the message, so that was no good.
The problem occurs 4000ish characters into the text, I do not know if that is significant. I have set the two values, mssql.textlimit and mssql.textsize to 65000 in the php.ini file.
I have now found the answer, I needed to set the odbc.defaultlrl value in the php.ini file, my database connection is an ODBC one.

How to import Romanian diacritics from csv to mysql database

i have found one error on my script.
While is importing from csv file to MySQL database diacritics shown strange char.
i need fast and realiable solution in SQL query in my code below:
$sql = "INSERT into medici (`cnp`, `cod_parafa`, `tit_id`, `numele`, `numele_anterior`,...
what i need is importing fields: numele and numele_anterior with support my romanian char like șțăîâ.
My database has set utf8_romanian_ci char.

Datatables mysql charset circumflex

I have a mysql database with latin1 default character set name.
Through php I save strings in mysql table. From the table I parse some data into tables using DataTables.
Everything work ok, but now I have some problems with circumflex letters and FPDF.
So if I save a string "račun" in the table, the result in the table will be "raÄun".
Or the string "število" will be "Å¡tevilo".
OK -> DataTables decodes those words back normally..
But now when I am using FPDF it gets those string as they are stored in MySQL table and print them "encoded".
I tried
iconv("ISO-8859-1", "ISO-8859-2", "Števika računa")
and
utf8_decode("Števika računa)
But nothing worked.. does anybody has an idea what should I do?
At the end this was the solution:
http://isabelcastillo.com/international-characters-encoding-fpdf

String is not saved correctly in database

I am trying to save a string in database and get something like this
&#1055&#1077&#1088&#1080&#1086&#1076&#32&#1076&#10
The string that I want to save : Период действия S...
The table encoding is: cp1251_general_ci
I don't know in which encoding the string is - I am getting it from an excel document.
I tried this, but it didn' help.
$nomer = iconv('UTF-8','Windows-1251', $str );
Is there a solution for this?
You haven't mentioned the database engine you're using, but try changing the table encoding to something like utf8_general_ci or utf8_unicode_ci.

Categories