简体   繁体   中英

How to Fetch Data in Hindi and Gujarati Language in MySQL?

Below my code i try this solution but not work it. and also i give utf8_unicode_ci for hindi and utf8_bin for Gujarati Language in database Collation.

Please Help me how i fetch data Hindi & Gujarati Language.

 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<?php
session_start();
        require_once('config.php'); 
        $JSONoutput = array();
        $q=mysqli_query($con,"SELECT * FROM tbl_Hindi");


    header('Content-Type: text/html; charset=UTF-8');
            while($rs=mysqli_fetch_assoc($q))
            {
                $JSONoutput['SMS'][] = array("ID"=>$rs['ID'],"Message"=>$rs['Message']);
            }
            print(json_encode($JSONoutput));
    ?>

Output:

{"SMS":[{"ID":"1","Message":"?? ????? ?? ??? ???? ??, ???? ?? ???? ??? ?? ????? ?? ?? ???? ?? ??????"},{"ID":"2","Message":"???? ????? : ??? ???? ?? ? ????? ????? : shopping ???? ?? ??? ???? ????? : : ???? ?? ???? ? ????? ????? : ???? ??? ??? ?? Gf ?? ? ???? ????? : ?? ?? ??? ??? ?? ? ????? ????? : ?? ???? "}]}
  1. Your sql table change field format change language collection utf16_general_ci all language accept.

ALTER TABLE tbl_Hindi CHANGE Message Message VARCHAR( 50 ) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL ;

Try this query

See https://stackoverflow.com/a/38363567/1766831 -- In particular the discussion of "Question marks". It says

  • The bytes to be stored are not encoded as utf8/utf8mb4. Fix this.
  • The column in the database is CHARACTER SET utf8 (or utf8mb4). Fix this.
  • Also, check that the connection during reading is UTF-8.

The question marks are already in the database table; the original data is lost.

Do not us ucs2 or utf16; use only utf8 or utf8mb4.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM