tracker issue : CF-4206938

select a category, or use search below
(searches all categories and all time range)
Title:

Emojis cause replace() to malfunction

| View in Tracker

Status/Resolution/Reason: To Fix//BugVerified

Reporter/Name(from Bugbase): Sammud S. / ()

Created: 02/04/2020

Components: Language, String Functions

Versions: 2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: CF 2018 /

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 6

Problem Description:

Adding certain unicode characters (for example ??) cause weirdness in the replace() and replaceNoCase() functions.

Steps to Reproduce/Actual Result/Expected Result:

replace("The rich man spent all his ?? money ?? on clothes!", "clothes", "cars")
output: The rich man spent all his ?? money ?? ocarses!

replace("???? The rich man spent all his ?? money ?? on clothes!", "clothes", "cars")
output: ???? The rich man spent all his ?? money ??carsthes!

I also noticed that len("??") is 2, and that the replace is off by the same number of characters as the preceding emojis. In the first example there are 2 emojis and "cars" is added to the left by 2 characters, replacing "n " and not replacing "es". In the second example there are 4 emojis and "cars" is added to the left by 4 characters, replacing " on " and not replacing "thes".

Any Workarounds:

Using reReplace() and reReplaceNoCase() gets around this issue.

Attachments:

Comments: