HTMLencoded2Text ( )

Function stats

Average user rating
4.0000
37
178
9999
Support
FileMaker 10.0 +
Date posted
07 January 2009
Last updated
14 May 2009
Version
Recursive function
Yes

Author Info
 Fabrice

38 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

HTMLencoded2Text  ( _text )


Parameters

_text  


Description

Tags:  Text   HTML   Encoding  

Translates HTML encoded text into standard text

Examples

Sample input

HTMLencoded2Text ( "Smith&Wesson" )
or
HTMLencoded2Text ( "Smith&Wesson" )


Sample output

Smith&Wesson

 

Function code

/* HTMLencoded2Text ( _text )

by Fabrice Nordmann

v.1.2 - Mar 2009
- handles long unicodes
v.1.1.1 - Jan 2009
- added more HTML entities
v.1.1 - Jan 2009
- added the HTML entities
v.1.0 - Jan 2009


Translates HTML encoded text into standard text

example :
HTMLencoded2Text ( "Smith&Wesson" ) = "Smith&Wesson"


Requires FileMaker 10

Recursive function
*/

Let ( _text = Substitute ( _text
; [ "&" ; "&" ]
; [ "&lt;" ; "<" ]
; [ "&gt;" ; ">" ]
; [ "&quot;" ; "\"" ]
; [ "&apos;" ; "'" ]
; [ "&nbsp;" ; " " ]
; [ "&iexcl;" ; "¡" ]
; [ "&cent;" ; "¢" ]
; [ "&pound;" ; "£" ]
; [ "&curren;" ; "¤" ]
; [ "&yen;" ; "¥" ]
; [ "&brvbar;" ; "¦" ]
; [ "&sect;" ; "§" ]
; [ "&uml;" ; "¨" ]
; [ "&copy;" ; "©" ]
; [ "&ordf;" ; "ª" ]
; [ "&laquo;" ; "«" ]
; [ "&not;" ; "¬" ]
; [ "&shy;" ; "­" ]
; [ "&reg;" ; "®" ]
; [ "&macr;" ; "¯" ]
; [ "&deg;" ; "°" ]
; [ "&plusmn;" ; "±" ]
; [ "&sup2;" ; "²" ]
; [ "&sup3;" ; "³" ]
; [ "&acute;" ; "´" ]
; [ "&micro;" ; "µ" ]
; [ "&middot;" ; "·" ]
; [ "&cedil;" ; "¸" ]
; [ "&sup1;" ; "¹" ]
; [ "&ordm;" ; "º" ]
; [ "&raquo;" ; "»" ]
; [ "&frac14;" ; "¼" ]
; [ "&frac12;" ; "½" ]
; [ "&frac34;" ; "¾" ]
; [ "&iquest;" ; "¿" ]
; [ "&Agrave;" ; "À" ]
; [ "&Aacute;" ; "Á" ]
; [ "&Acirc;" ; "Â" ]
; [ "&Atilde;" ; "Ã" ]
; [ "&Auml;" ; "Ä" ]
; [ "&Aring;" ; "Å" ]
; [ "&AElig;" ; "Æ" ]
; [ "&Ccedil;" ; "Ç" ]
; [ "&Egrave;" ; "È" ]
; [ "&Eacute;" ; "É" ]
; [ "&Ecirc;" ; "Ê" ]
; [ "&Euml;" ; "Ë" ]
; [ "&Igrave;" ; "Ì" ]
; [ "&Iacute;" ; "Í" ]
; [ "&Icirc;" ; "Î" ]
; [ "&Iuml;" ; "Ï" ]
; [ "&ETH;" ; "Ð" ]
; [ "&Ntilde;" ; "Ñ" ]
; [ "&Ograve;" ; "Ò" ]
; [ "&Oacute;" ; "Ó" ]
; [ "&Ocirc;" ; "Ô" ]
; [ "&Otilde;" ; "Õ" ]
; [ "&Ouml;" ; "Ö" ]
; [ "&times;" ; "×" ]
; [ "&Oslash;" ; "Ø" ]
; [ "&Ugrave;" ; "Ù" ]
; [ "&Uacute;" ; "Ú" ]
; [ "&Ucirc;" ; "Û" ]
; [ "&Uuml;" ; "Ü" ]
; [ "&Yacute;" ; "Ý" ]
; [ "&THORN;" ; "Þ" ]
; [ "&szlig;" ; "ß" ]
; [ "&agrave;" ; "à" ]
; [ "&aacute;" ; "á" ]
; [ "&acirc;" ; "â" ]
; [ "&atilde;" ; "ã" ]
; [ "&auml;" ; "ä" ]
; [ "&aring;" ; "å" ]
; [ "&aelig;" ; "æ" ]
; [ "&ccedil;" ; "ç" ]
; [ "&egrave;" ; "è" ]
; [ "&eacute;" ; "é" ]
; [ "&ecirc;" ; "ê" ]
; [ "&euml;" ; "ë" ]
; [ "&igrave;" ; "ì" ]
; [ "&iacute;" ; "í" ]
; [ "&icirc;" ; "î" ]
; [ "&iuml;" ; "ï" ]
; [ "&eth;" ; "ð" ]
; [ "&ntilde;" ; "ñ" ]
; [ "&ograve;" ; "ò" ]
; [ "&oacute;" ; "ó" ]
; [ "&ocirc;" ; "ô" ]
; [ "&otilde;" ; "õ" ]
; [ "&ouml;" ; "ö" ]
; [ "&divide;" ; "÷" ]
; [ "&oslash;" ; "ø" ]
; [ "&ugrave;" ; "ù" ]
; [ "&uacute;" ; "ú" ]
; [ "&ucirc;" ; "û" ]
; [ "&uuml;" ; "ü" ]
; [ "&yacute;" ; "ý" ]
; [ "&thorn;" ; "þ" ]
; [ "&yuml;" ; "ÿ" ]
; [ "&le;" ; "≤" ]
; [ "&ge; " ; "≥" ]
; [ "&para;" ; "\¶" ]
; [ "&ldquo;" ; "\"" ]
; [ "&rdquo;" ; "\"" ]
)
;
Case ( not PatternCount ( _text ; "&#" ) ; _text
; Let ([
_pos = Position ( _text ; "&#" ; 1 ; 1 )
; _pos2 = Position ( _text ; ";" ; _pos ; 1 ) - _pos
; _word = Middle ( _text ; _pos ; _pos2 + 1 )
; _isCode = Length ( _word ) >= 4 and Length ( _word ) <= 8 and Substitute ( _word ; [ 0 ; "" ] ; [ 1 ; "" ] ; [ 2 ; "" ] ; [ 3 ; "" ] ; [ 4 ; "" ] ; [ 5 ; "" ] ; [ 6 ; "" ] ; [ 7 ; "" ] ; [ 8 ; "" ] ; [ 9 ; "" ]) = "&#;"
; _result = Left ( _text ; _pos - 1 ) & Case ( _isCode ; Char ( GetAsNumber ( _word )) ; "&" )
];
_result & HTMLencoded2Text ( Right ( _text ; Length ( _text ) - ( _pos + Case ( _isCode ; Length ( _word ) - 1 ))))
)
))

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/178

    Prototype: HTMLencoded2Text( _text )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 14 May 2009
    Version: 3.2

*/
// ===================================

 

Comments

Agnès
03 May 2009



Hello Fabrice,

During an import, I found myself with those here who was not in your list
; [ "&le;" ; "≤" ]
; [ "&ge; " ; "≥" ]
; [ "&para;" ; Citation ( "#|^|#¶#|^|#" ) ]
; [ "\"#|^|#" ; "" ]; [ "#|^|#\"" ; "" ]
; [ "&ldquo;" ; "\"" ]
; [ "&rdquo;" ; "\"" ]

in cazou
Thanks a lots for this one !

Agnès
(Edited by Agnès on 03/05/09 )
  General comment

 

 


Login or register to comment

Create a new account with fmcustomfunctions.com or login to post a comment.

 

 

 

Top Tags

Text Parsing  (24)
List  (19)
XML  (15)
Format  (14)
Date  (14)
Debug  (12)
Layout  (11)
Variables  (10)
Filter  (9)
ValueIterator  (6)
Layout Objects  (6)
Number  (5)
Recursive  (5)
Dev  (5)
Interface  (5)
Text  (5)