Posts

Showing posts with the label utf8

Connecting to MySQL 8 from Old PHP version using mysqli

If you have upgraded your MySQL to MySQL 8 version and still using older version of PHP you might encounter a few problems in the connection using mysqli connector library. 1. The first problem we are going to solve is: php mysql 8: "Server sent charset (255) unknown to the client. Please, report to the developers" The problem is that MySQL have changed the default character set from utf8 to utf8mb4 and it is not supported by mysqli connector (nor PDO as I have checked) in older versions of php. "The default collation for utf8mb4 differs between MySQL 5.7 and 8.0 ( utf8mb4_general_ci for 5.7, utf8mb4_0900_ai_ci for 8.0). When the 8.0 client requests a character set of utf8mb4 , what it sends to the server is the default 8.0 utf8mb4 collation; that is, the utf8mb4_0900_ai_ci." https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html The way to solve it easily (there are other ways, such as upgrading php or connectors and more ...) is to force MySQL 8.0 to ...

Find files with BOM in linux command line

 grep -rl $'\xEF\xBB\xBF' .

איך לשמור אימוג'י בדטאבייס MySQL 😀

How To Save Emoji in MySQL Database 😝😚 כדי לשמור סימנים מיוחדים בדטאבייס לעיתים UTF8 לא מספיק ולכן נשתמש ב - Collate מתאים ל - MultiBytes 1. ALTER DATABASE DatabaseName CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; 2. ALTER TABLE Tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; 3. $database_connection = new mysqli($server, $user, $password, $database_name);   $database_connection->set_charset('utf8mb4'); https://stackoverflow.com/questions/39463134/how-to-store-emoji-character-in-my-sql-database ותודה לאח שלי חצב !

האפשרות ש - Microsoft Excel יוכל לקרוא קובץ CSV ב - UTF-8

עבודה עם אקסל יכולה להיות מאוד מרגיזה לפעמים. לצערנו Excel עדיין עובד בברירת המחדל ב - Windows-1255 Encoding. אבל מה אם אנחנו רוצים ליצור קובץ CSV מתקדם יותר ... נניח UTF8. הפתרון נמצא ב - BOM :  header("Content-Type: text/csv; charset=UTF-8");  header("Content-Disposition: attachment; filename=$filename"); // Disable caching  header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1  header("Pragma: no-cache"); // HTTP 1.0  header("Expires: 0"); // Proxies  $out = fopen('php://output', 'w');  $BOM = "\xEF\xBB\xBF"; // UTF-8 BOM  fwrite($out, $BOM);  $headlines = array("a", "b", "c");  fputcsv($out, $headlines);  // loop data here  fclose($out);

הוספת BOM UTF-8 לקבצים ב - PHP

$csv_file  = fopen("barvaz/barvazon.csv", 'w') or die("can't create bar baz"); fwrite($csv_file, "\xEF\xBB\xBF");

UTF8 ובסיסי נתונים MySQL Database

זה כבר כמה זמן אני מעוניין לכתוב על ניהול נכון של Encoding בבניית אתרי אינטרנט. אנשים נוטים לבצע טעויות רבות ולא מבינים את המשמעות שבין UTF-8 לבין תקני ISO ותקנים של Windows כגון Windows-1255. הבעיות מופיעות בבחירה לא נכונה של Charset הן בבניית העמוד והן בשמירה ב - Database. לצערי אין לי את הזמן כרגע, אבל אני בוודאי שעוד אחזור לכך ואסביר את כל שלבי ה - Encoding מה - Datbase דרך ה - Webserver וכלה בדף ה- HTML והתצוגה בדפדפן. כרגע אני משתף קוד קצר ל - mysql שימיר לנו שדות טקסט ששמרנו בהם עברית ב - Charset latin1 ל - UTF8. ALTER TABLE files ADD COLUMN temp TEXT CHARACTER SET utf8 COLLATE utf8_general_ci AFTER text; -- add the temp column UPDATE files SET temp=CONVERT(CONVERT(text USING binary) USING utf8); -- convert the data to the new column ALTER TABLE files DROP COLUMN text; -- drop original column ALTER TABLE files CHANGE temp text TEXT CHARACTER SET utf8 COLLATE utf8_general_ci; -- rename temp column Change hebrew / or other charset inside MySQL to UTF-8.