Created
December 6, 2024 16:41
-
-
Save JamoCA/da8d38a409d41fd4b7abccd782124775 to your computer and use it in GitHub Desktop.
Convert all Windows-1252 & unicode dashes in a string to a specified character (default=ASCII 45 dash) using ColdFusion/CFML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* sanitizeDash - Converts all Windows-1252 & unicode dashes in a string to a specified character (default=ASCII 45 dash) | |
2024-12-06 | |
Author: James Moberg http://sunstarmedia.com @sunstarmedia | |
GIST: https://gist.github.com/JamoCA/da8d38a409d41fd4b7abccd782124775 | |
*/ | |
string function sanitizeDash(inputString="", numeric dashAscii=45) hint="I normalize all Windows-1252 & unicode dashes in a string to a specified character" { | |
return javacast("string", arguments.inputString).replaceAll("#chr(45)#|#chr(150)#|#chr(151)#|#chr(173)#|#chr(8208)#|#chr(8209)#|#chr(8210)#|#chr(8211)#|#chr(8212)#|#chr(8213)#|#chr(8722)#|#chr(11799)#|#chr(11834)#|#chr(11835)#|#chr(65112)#|#chr(65123)#", chr(arguments.dashAscii)); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment