0

I have a set of queries which I have tried to run in mysql server using this command:

mysql -ufourint -pjabberwocky -hdb1 cafe  < /tmp/bhasha_templates.txt

The file bhasha_templates.txt has been created by me in notepad using UTF 8 encoding.

I also tried encoding in UTF8 BOM and ANSI but it doesn't seem to work for the Hindi language.

Sample:

INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.message.noResultFound','माफ़ कीजिए। हमें कोई जानकारी नहीं मिली। क्या आप चाहेंगे');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.message.noResultFoundAddListing','एक सूची जोड़ें?');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.message.similarSearch','के लिए खोजें');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.text.AlsoFound','यह भी पाया गया:');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.text.seeAll','सभी देखिएँ');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.text.seeAlso','यहाँ भी देखें');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.text.suggestItems','आप अन्य देखना चाहेंगे');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.text.ViewContactDetails','सम्पर्क करने के लिए विवरण देखें');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.Articles','ये लेख आपके लिये दिलचस्प हो सकता है');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.cardPhoneNumber','${locality},${cityName} में ${name},${category} के संपर्क के लिए फोन नंबर');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.compareResults','प्रमुख परिणामों की तुलना');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.Events','कार्यक्रम');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.inAndNear','${where},${cityName} में और निकटत्तम् ${what}');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.Movies','फिल्म');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.title.topSearch','प्रमुख खोजें');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.tooltip.HeadOffice','मुख्य कार्यालय');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','hindi','srp.tootltip.Services','सेवाएँ');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.advertise','Advertise with asklaila');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.Android','AskLaila StreetSmart Local Search Mobile App on Andoid');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.blog','Asklaila Blogs');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.brandLocator','Brand Locator');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.CityGuide','CITY GUIDE');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.cityScape','CityScape');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.contactUs','Contact Us');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.corporate','CORPORATE');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.FAQ','Frequently Asked Questions');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.iOS','AskLaila StreetSmart Local Search Mobile App on iOS');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.localityGuide','${cityName} Locality Guide');
INSERT INTO cafe.bhasha_templates( `module`,  `language`,  `key`,  `value`) VALUES ('CAFE','english','footer.title.Mobile','MOBILE');

I have made sure that my DB table is also in COLLATION_NAME: utf8_general_ci and so are the columns.

But when I view the same in my application i can see text as :

शहर का मारà¥à¤—दरà¥à¤¶à¤•


Bangalore मारà¥à¤—दरà¥à¤¶à¤•

Bangalore सà¥à¤¥à¤¾à¤¨à¥€à¤¯ मारà¥à¤—दरà¥à¤¶à¤•

बà¥à¤°à¤¾à¤‚ड लोकेटर

लोकपà¥à¤°à¤¿à¤¯ पà¥à¤°à¤¶à¥à¤

I have rechecked that my encoding does not have latin1 anywhere but I am still unable to figure out why it is happening.I suspect it may have something to do with inserting using UNIX.

The same code in my local DB and application wherein im using SQLYog insert is working fine. But in my prod DB it is coming messed.

Please advice.

¨

Aman Garg
  • 21
  • 6

2 Answers2

0

Run this in command line:

mysql --default-character-set=utf8

If you want to check character-set, you can check:

mysql > SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'DATABASE_NAME';
Abdullah Al Shakib
  • 2,034
  • 2
  • 15
  • 16
  • my default charset is: | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | | utf8 | utf8_general_ci | though everytime i run this before a single insert statement it seems to work: SET NAMES 'utf8' COLLATE 'utf8_general_ci' but i have to do this before every insert statement for some reason. – Aman Garg Dec 14 '15 at 08:42
0

मार becomes माठvia "Mojibake":

  • The bytes you have in the client are correctly encoded in utf8 (good).
  • You connected with SET NAMES latin1 (or set_charset('latin1') or ...), probably by default. (It should have been utf8.)
  • The column in the tables may or may not have been CHARACTER SET utf8, but it should have been that.

The init-connect setting (init-connect='SET NAMES utf8') is not skipped when root starts up. Be sure to do it manually if you are using root.

Rick James
  • 135,179
  • 13
  • 127
  • 222