Based on the screenshots you provided, it looks like the file is encoded in UTF-16 Little Endian (LE). This is why you see the characters spaced out in the MySQL table import, as UTF-16 uses two bytes per character.
To import this file into a UTF-8 MySQL table, you’ll need to convert the file to UTF-8 first. You can do this using a text editor that supports encoding conversion, or by using a command-line tool like iconv
.
-
تحسين تجربة البرمجة في Sublime Text 302/02/2024
-
كيفية تحديد الأخطاء الإملائية في PyCharm05/03/2024
-
تبديل عرض كلمة المرور في أندرويد14/03/2024
Here’s a general approach using iconv
:
-
Convert the file to UTF-8:
bashiconv -f UTF-16LE -t UTF-8 inputfile.txt > outputfile.txt
Replace
inputfile.txt
with the name of your downloaded file andoutputfile.txt
with the name you want for the converted file. -
Import the converted file into MySQL:
Once you have the file in UTF-8 encoding, you can import it into your MySQL table using theLOAD DATA INFILE
statement. Make sure your MySQL table is set to use UTF-8 encoding.sqlLOAD DATA INFILE 'path_to_your_file/outputfile.txt' INTO TABLE your_table_name CHARACTER SET UTF8 FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (column1, column2, ...);
Adjust the
CHARACTER SET
,FIELDS TERMINATED BY
,LINES TERMINATED BY
, and the list of columns(column1, column2, ...)
according to your file format and table structure.
This should allow you to safely import the UTF-16 file into your UTF-8 MySQL table without the spacing issue.
المزيد من المعلومات
الملف الذي تعمل عليه مشفر بترميز UTF-16 Little Endian، وهذا ما يفسر الفراغات بين الحروف عند استيراده إلى جدول MySQL الذي يستخدم ترميز UTF-8. يجب عليك تحويل الترميز إلى UTF-8 قبل استيراده إلى جدول MySQL.
يمكنك استخدام أدوات التحويل المتاحة لتحويل ترميز الملف. على سبيل المثال، يمكنك استخدام أداة iconv
في نظام التشغيل Linux لتحويل الترميز. الأمر التالي يوضح كيفية استخدام iconv
لتحويل الملف إلى UTF-8:
bashiconv -f UTF-16LE -t UTF-8 inputfile.txt > outputfile.txt
يجب استبدال inputfile.txt
باسم الملف الذي قمت بتنزيله و outputfile.txt
باسم الذي تريده للملف المحول.
بعد تحويل الترميز، يمكنك استيراد الملف المحول إلى جدول MySQL الخاص بك باستخدام الأمر LOAD DATA INFILE
بالطريقة التي تم ذكرها في الرد السابق.