News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

UTF-8 string messages php converter

Started by nishuFun, May 14, 2022, 02:41:20 PM

Previous topic - Next topic

nishuFun

I have this hindi(devnagri) font + emoji + utf-8 string

Quoteमेरा 👉🏻Attitude तो मेरी #निशानी है,
➡️ 𝐃𝐨𝐧'𝐭 𝐒𝐡𝐨𝐰 𝐌𝐞 𝐘𝐨𝐮𝐫 𝐀𝐭𝐭𝐢𝐭𝐮𝐝𝐞 !!
💯#𝑨𝒕𝒕𝒊𝒕𝒖𝒅𝒆𝑨𝒑𝒑 ✓

Now, i am writing a php or js function to convert and save it in db.smg_messages table.

can u please advice me what are necessary conversion i need to consider?

i had wrote my own code but in html entity conversion  i m losing words. e.g. 💯#𝑨𝒕𝒕𝒊𝒕𝒖𝒅𝒆𝑨𝒑𝒑 ✓

a code will help me a lot.

smf 2.1.2

jillianmontague

You can use built-in functions like
echo()
md5()
str_split()
str_word_count()
strlen()
substr()

shawnb61

If your SMF is already utf8, and you're using php, no conversion is necessary.  Just copy the string.

One exception would be if there are 4-byte utf8 chars in the source data, e.g., emojis.  SMF still uses mysql's older limited utf8 implementation that does not support those.  Those would need to be detected & converted to html entities.  If you run into this, you can use SMF's routines to do so.

I would call reloadSettings(), and experiment with:
$smcFunc['htmlspecialchars']() and $smcFunc['fix_utf8mb4']()

A question worth asking is born in experience & driven by necessity. - Fripp

Davey2

The utf8_encode() function is an inbuilt function in PHP which is used to encode an ISO-8859-1 string to UTF-8. Unicode has been developed to describe all possible characters of all languages and includes a lot of symbols with one unique number for each symbol/character.

Advertisement: