the problem with the Russian encoding in the LOAD DATA LOCAL INFILE function

xxxxxx2's profile image xxxxxx2 posted 8 years ago in General Permalink

Hey. I use heidisql 9.3.0.4984 on Win 7 x64. there is a table and a database encoded in utf 8. I use the following code to download the file with Russian letters in the encoding cp1251:

LOAD DATA LOCAL INFILE 'c:/history.csv'
INTO TABLE coesia CHARACTER SET cp1251
FIELDS TERMINATED BY ';' 
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(nomer,centr,tipop,@createdate,operator,`status`)
SET createdate = STR_TO_DATE(@createdate, '%d.%m.%Y');
through delphi I send commands:
SET CHARSET cp1251;
SET NAMES cp1251;
LOAD DATA LOCAL INFILE 'c:/history.csv'
INTO TABLE coesia CHARACTER SET cp1251
FIELDS TERMINATED BY ';' 
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(nomer,centr,tipop,@createdate,operator,`status`)
SET createdate = STR_TO_DATE(@createdate, '%d.%m.%Y');

and all the letters are loaded correctly when I execute this code (with the commands SET and without them) in heidisql Russian letters are converted here in this: ���� �� �. ������ � �������� ������ What shall I do in order to file with Russian letters through heidisql loaded correctly?

ansgar's profile image ansgar posted 8 years ago Permalink

I guess your file is not cp1251 encoded, but probably utf-8 already? Try again with CHARACTER SET utf8?

xxxxxx2's profile image xxxxxx2 posted 8 years ago Permalink

No exact file encoding cp1251. strange. the code is now earned a CHARACTER SET cp1251. when I put utf8 I get a warning Incorrect string value: '\xD3\xCF\xD4\xD0 \xEF...' for column 'centr' at row 1 I do not know what it was. Excuse for troubling))

Please login to leave a reply, or register at first.