Using emojis in issue

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
zio3d
Posts: 5
Joined: 04 Aug 2017, 10:23
Location: Treviso, Italy

Using emojis in issue

Post by zio3d »

Hello!
I downloaded the latest version 2.25.5 of Mantis Bug Table.
As soon as it was installed I tried to insert emoji (No emoticons) in the summary of the bug, for example 😅🤔😄 but they are not stored.
If I manually edit the 'summary' record of the "mantis_bug_table" table they are stored but not displayed.
I also tried to transform all fields to both 'utf8mb4_general_ci' and 'utf8mb4_unicode_520_ci' but the result did not change.
In its place I find the characters '�'.
I seemed to have understood by reading here and there on the forum that emojis were managed ...
Am I wrong or do I have to set some additional parameters?
I am using Apache (Wamp 3.2.6 64 bit) on Windows 10 21H1 64 bit, database MySql 5.7.19, PHP 7.4.26.
Thank you.
atrol
Site Admin
Posts: 8187
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Using emojis in issue

Post by atrol »

At the moment MantisBT can't work out of the box with full support of utf8mb4.
That's planned for future versions, see https://www.mantisbt.org/bugs/view.php?id=20431
Some emojis work, but emojis needing utf8mb4 are replaced by a placeholder when storing.
If you have setup your database with utf8mb4, it might work (I didn't try) if you change function db_mysql_fix_utf8 in file core/database_api.php
from

Code: Select all

function db_mysql_fix_utf8( $p_string ) {
	if( !db_is_mysql() ) {
		return $p_string;
	}
	return preg_replace(
		# 4-byte UTF8 chars always start with bytes 0xF0-0xF7 (0b11110xxx)
		'/[\xF0-\xF7].../s',
		# replace with U+FFFD to avoid potential Unicode XSS attacks,
		# see http://unicode.org/reports/tr36/#Deletion_of_Noncharacters
		"\xEF\xBF\xBD",
		$p_string
	);
}
to

Code: Select all

function db_mysql_fix_utf8( $p_string ) {
		return $p_string;
}
Please use Search before posting and read the Manual
zio3d
Posts: 5
Joined: 04 Aug 2017, 10:23
Location: Treviso, Italy

Re: Using emojis in issue

Post by zio3d »

Thanks for the info.
I tried to convert all the fields in "utf8mb4_unicode_520_ci" format and make the change to the "db_mysql_fix_utf8" function as you indicated, but when I press the "Update Information" button (after entering "TEST 😍🤔😅" in the summary), I have the error:

Code: Select all

APPLICATION ERROR #401

Database query failed. Error received from database was #1366: Incorrect string value: '\xF0\x9F\x98\x8D\xF0\x9F...' for column 'summary' at row 1 for the query: UPDATE mantis_bug_table
SET project_id=?, reporter_id=?,
handler_id=?, duplicate_id=?,
priority=?, severity=?,
reproducibility=?, status=?,
resolution=?, projection=?,
category_id=?, eta=?,
os=?, os_build=?,
platform=?, version=?,
build=?, fixed_in_version=?,
target_version=?,
view_state=?,
summary=?,
sponsorship_total=?,
sticky=?,
due_date=?
WHERE id=?.
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.
It is not just a problem of executing the edit query.
If I try to modify the value of the "Summary" field directly in the database with "TEST 😍🤔😅", I don't see it correctly in the bug tracker (I see the string "TEST ???" in its place).

But since you write me "That's planned for future versions", then I'll wait for future versions.

Thank you.
Davide.
Post Reply