web_encode
Converts non ascii characters to html entities for use on a webpage
Average rating: 4.7 (18 votes) Log in to vote
Jens Teich - Show more from this author
DJTO http://jensteich.de |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Conversion of non ASCII is built in but hidden. Function Get_as_css does is. We only have to chop of a bit at both ends.
Comments
Dan Shockley May 27, 2025 |
||
Note that this will fail if your input text has any style, text color, or font sizing, etc. | ||
Dan Shockley May 28, 2025 |
||
So, if you are ok with stripping away any text style/size/font in order to get easy conversion of high ascii characters into HTML-encoded entities, you could change this function to: Let ( [ a = GetAsCSS ( TextFormatRemove ( someText ) ) ; len = Length ( a ) ]; Middle ( a ; 17 ; len - 23 ) ) That way, any styling is removed first, so that the simple trimming away of the original function above works. If you'd like the function to be more specific about how it works, making it easier to update if there is a change in how FileMaker tags the HTML, you could use this: // TextPlainEncodeToHTML ( someText ) // v 2025-05-28 /* Converts the incoming text into HTML-encoded text AFTER stripping any formatting. HISTORY: 2025-05-28 ( danshockley ): Updated to be more clear about how it works. 2025-05-27 ( danshockley ): Created, based on idea by Jens Teich, DJTO, http://jensteich.de - code at https://www.briandunning.com/cf/1849. */ Let ( [ cssEncoded = GetAsCSS ( TextFormatRemove ( someText ) ) ; lenCSS = Length ( cssEncoded ) ; startTag = "" ; endTag = "" ; posStartTag = Position ( cssEncoded ; startTag ; 1 ; 1 ) ; posGoodTextStarts = If ( posStartTag > 0 ; posStartTag + Length ( startTag ) ; 1 ) ; posTagAfterBegins = Position ( cssEncoded ; endTag ; -1 ; 1 ) ; lenGoodText = If ( posTagAfterBegins > 0 ; posTagAfterBegins - posGoodTextStarts ; lenCSS - posGoodTextStarts + 1 ) ]; Middle ( cssEncoded ; posGoodTextStarts ; lenGoodText ) ) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.