0

Is there any way to save Bengali Language content in database without encoding, like: আমার will be saved exactly as আমার. But it is inserted as গলà§à¦ªà§‡ গলà§à¦ªà§‡ সি পà§à. it is being coded before save but how could I prevent this automatic encoding?

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
  • Which database system are you using? How have you created the database (it should be at least UTF-8)? Provide the "CREATE DATABASE" statement (or the equivalent). – Risadinha Jun 08 '16 at 15:33

1 Answers1

0

In this case, I would prefer using urlencode and urldecode. So before it is sent to the DB, I'll use:

urlencode($content);        // %E0%A6%86%E0%A6%AE%E0%A6%BE%E0%A6%B0

And while displaying:

echo urldecode($content);   // আমার

Output:

This way, it is safe to be stored. But only one issue is, the content's length in URL Encode will be larger than the original one.

But the right way, is to use UTF8-MB4 or similar Encoding in the Database. Eg. in MySQL:

CREATE TABLE `whatever` (
  -- Fields
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252