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
; [ "&" ; "&" ]
; [ "<" ; "<" ]
; [ ">" ; ">" ]
; [ """ ; "\"" ]
; [ "'" ; "'" ]
; [ " " ; " " ]
; [ "¡" ; "¡" ]
; [ "¢" ; "¢" ]
; [ "£" ; "£" ]
; [ "¤" ; "¤" ]
; [ "¥" ; "¥" ]
; [ "¦" ; "¦" ]
; [ "§" ; "§" ]
; [ "¨" ; "¨" ]
; [ "©" ; "©" ]
; [ "ª" ; "ª" ]
; [ "«" ; "«" ]
; [ "¬" ; "¬" ]
; [ "­" ; "" ]
; [ "®" ; "®" ]
; [ "¯" ; "¯" ]
; [ "°" ; "°" ]
; [ "±" ; "±" ]
; [ "²" ; "²" ]
; [ "³" ; "³" ]
; [ "´" ; "´" ]
; [ "µ" ; "µ" ]
; [ "·" ; "·" ]
; [ "¸" ; "¸" ]
; [ "¹" ; "¹" ]
; [ "º" ; "º" ]
; [ "»" ; "»" ]
; [ "¼" ; "¼" ]
; [ "½" ; "½" ]
; [ "¾" ; "¾" ]
; [ "¿" ; "¿" ]
; [ "À" ; "À" ]
; [ "Á" ; "Á" ]
; [ "Â" ; "Â" ]
; [ "Ã" ; "Ã" ]
; [ "Ä" ; "Ä" ]
; [ "Å" ; "Å" ]
; [ "Æ" ; "Æ" ]
; [ "Ç" ; "Ç" ]
; [ "È" ; "È" ]
; [ "É" ; "É" ]
; [ "Ê" ; "Ê" ]
; [ "Ë" ; "Ë" ]
; [ "Ì" ; "Ì" ]
; [ "Í" ; "Í" ]
; [ "Î" ; "Î" ]
; [ "Ï" ; "Ï" ]
; [ "Ð" ; "Ð" ]
; [ "Ñ" ; "Ñ" ]
; [ "Ò" ; "Ò" ]
; [ "Ó" ; "Ó" ]
; [ "Ô" ; "Ô" ]
; [ "Õ" ; "Õ" ]
; [ "Ö" ; "Ö" ]
; [ "×" ; "×" ]
; [ "Ø" ; "Ø" ]
; [ "Ù" ; "Ù" ]
; [ "Ú" ; "Ú" ]
; [ "Û" ; "Û" ]
; [ "Ü" ; "Ü" ]
; [ "Ý" ; "Ý" ]
; [ "Þ" ; "Þ" ]
; [ "ß" ; "ß" ]
; [ "à" ; "à" ]
; [ "á" ; "á" ]
; [ "â" ; "â" ]
; [ "ã" ; "ã" ]
; [ "ä" ; "ä" ]
; [ "å" ; "å" ]
; [ "æ" ; "æ" ]
; [ "ç" ; "ç" ]
; [ "è" ; "è" ]
; [ "é" ; "é" ]
; [ "ê" ; "ê" ]
; [ "ë" ; "ë" ]
; [ "ì" ; "ì" ]
; [ "í" ; "í" ]
; [ "î" ; "î" ]
; [ "ï" ; "ï" ]
; [ "ð" ; "ð" ]
; [ "ñ" ; "ñ" ]
; [ "ò" ; "ò" ]
; [ "ó" ; "ó" ]
; [ "ô" ; "ô" ]
; [ "õ" ; "õ" ]
; [ "ö" ; "ö" ]
; [ "÷" ; "÷" ]
; [ "ø" ; "ø" ]
; [ "ù" ; "ù" ]
; [ "ú" ; "ú" ]
; [ "û" ; "û" ]
; [ "ü" ; "ü" ]
; [ "ý" ; "ý" ]
; [ "þ" ; "þ" ]
; [ "ÿ" ; "ÿ" ]
; [ "≤" ; "≤" ]
; [ "≥ " ; "≥" ]
; [ "¶" ; "\¶" ]
; [ "“" ; "\"" ]
; [ "”" ; "\"" ]
)
;
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
*/
// ===================================
/* HTMLencoded2Text ( _text )__LITBR____LITBR__by Fabrice Nordmann__LITBR____LITBR__v.1.2 - Mar 2009__LITBR__ - handles long unicodes__LITBR__v.1.1.1 - Jan 2009__LITBR__ - added more HTML entities__LITBR__v.1.1 - Jan 2009__LITBR__ - added the HTML entities__LITBR__v.1.0 - Jan 2009__LITBR____LITBR____LITBR__Translates HTML encoded text into standard text__LITBR____LITBR__example :__LITBR__HTMLencoded2Text ( "Smith&Wesson" ) = "Smith&Wesson"__LITBR____LITBR____LITBR__Requires FileMaker 10__LITBR____LITBR__Recursive function__LITBR__*/__LITBR____LITBR__Let ( _text = Substitute ( _text__LITBR__; [ "&" ; "&" ]__LITBR__; [ "<" ; "<" ]__LITBR__; [ ">" ; ">" ]__LITBR__; [ """ ; "\"" ]__LITBR__; [ "'" ; "'" ]__LITBR__; [ " " ; " " ]__LITBR__; [ "¡" ; "¡" ]__LITBR__; [ "¢" ; "¢" ]__LITBR__; [ "£" ; "£" ]__LITBR__; [ "¤" ; "¤" ]__LITBR__; [ "¥" ; "¥" ]__LITBR__; [ "¦" ; "¦" ]__LITBR__; [ "§" ; "§" ]__LITBR__; [ "¨" ; "¨" ]__LITBR__; [ "©" ; "©" ]__LITBR__; [ "ª" ; "ª" ]__LITBR__; [ "«" ; "«" ]__LITBR__; [ "¬" ; "¬" ]__LITBR__; [ "­" ; "" ]__LITBR__; [ "®" ; "®" ]__LITBR__; [ "¯" ; "¯" ]__LITBR__; [ "°" ; "°" ]__LITBR__; [ "±" ; "±" ]__LITBR__; [ "²" ; "²" ]__LITBR__; [ "³" ; "³" ]__LITBR__; [ "´" ; "´" ]__LITBR__; [ "µ" ; "µ" ]__LITBR__; [ "·" ; "·" ]__LITBR__; [ "¸" ; "¸" ]__LITBR__; [ "¹" ; "¹" ]__LITBR__; [ "º" ; "º" ]__LITBR__; [ "»" ; "»" ]__LITBR__; [ "¼" ; "¼" ]__LITBR__; [ "½" ; "½" ]__LITBR__; [ "¾" ; "¾" ]__LITBR__; [ "¿" ; "¿" ]__LITBR__; [ "À" ; "À" ]__LITBR__; [ "Á" ; "Á" ]__LITBR__; [ "Â" ; "Â" ]__LITBR__; [ "Ã" ; "Ã" ]__LITBR__; [ "Ä" ; "Ä" ]__LITBR__; [ "Å" ; "Å" ]__LITBR__; [ "Æ" ; "Æ" ]__LITBR__; [ "Ç" ; "Ç" ]__LITBR__; [ "È" ; "È" ]__LITBR__; [ "É" ; "É" ]__LITBR__; [ "Ê" ; "Ê" ]__LITBR__; [ "Ë" ; "Ë" ]__LITBR__; [ "Ì" ; "Ì" ]__LITBR__; [ "Í" ; "Í" ]__LITBR__; [ "Î" ; "Î" ]__LITBR__; [ "Ï" ; "Ï" ]__LITBR__; [ "Ð" ; "Ð" ]__LITBR__; [ "Ñ" ; "Ñ" ]__LITBR__; [ "Ò" ; "Ò" ]__LITBR__; [ "Ó" ; "Ó" ]__LITBR__; [ "Ô" ; "Ô" ]__LITBR__; [ "Õ" ; "Õ" ]__LITBR__; [ "Ö" ; "Ö" ]__LITBR__; [ "×" ; "×" ]__LITBR__; [ "Ø" ; "Ø" ]__LITBR__; [ "Ù" ; "Ù" ]__LITBR__; [ "Ú" ; "Ú" ]__LITBR__; [ "Û" ; "Û" ]__LITBR__; [ "Ü" ; "Ü" ]__LITBR__; [ "Ý" ; "Ý" ]__LITBR__; [ "Þ" ; "Þ" ]__LITBR__; [ "ß" ; "ß" ]__LITBR__; [ "à" ; "à" ]__LITBR__; [ "á" ; "á" ]__LITBR__; [ "â" ; "â" ]__LITBR__; [ "ã" ; "ã" ]__LITBR__; [ "ä" ; "ä" ]__LITBR__; [ "å" ; "å" ]__LITBR__; [ "æ" ; "æ" ]__LITBR__; [ "ç" ; "ç" ]__LITBR__; [ "è" ; "è" ]__LITBR__; [ "é" ; "é" ]__LITBR__; [ "ê" ; "ê" ]__LITBR__; [ "ë" ; "ë" ]__LITBR__; [ "ì" ; "ì" ]__LITBR__; [ "í" ; "í" ]__LITBR__; [ "î" ; "î" ]__LITBR__; [ "ï" ; "ï" ]__LITBR__; [ "ð" ; "ð" ]__LITBR__; [ "ñ" ; "ñ" ]__LITBR__; [ "ò" ; "ò" ]__LITBR__; [ "ó" ; "ó" ]__LITBR__; [ "ô" ; "ô" ]__LITBR__; [ "õ" ; "õ" ]__LITBR__; [ "ö" ; "ö" ]__LITBR__; [ "÷" ; "÷" ]__LITBR__; [ "ø" ; "ø" ]__LITBR__; [ "ù" ; "ù" ]__LITBR__; [ "ú" ; "ú" ]__LITBR__; [ "û" ; "û" ]__LITBR__; [ "ü" ; "ü" ]__LITBR__; [ "ý" ; "ý" ]__LITBR__; [ "þ" ; "þ" ]__LITBR__; [ "ÿ" ; "ÿ" ]__LITBR__; [ "≤" ; "≤" ]__LITBR__; [ "≥ " ; "≥" ]__LITBR__; [ "¶" ; "\¶" ]__LITBR__; [ "“" ; "\"" ]__LITBR__; [ "”" ; "\"" ]__LITBR__)__LITBR__;__LITBR__Case ( not PatternCount ( _text ; "&#" ) ; _text __LITBR__; Let ([ __LITBR__ _pos = Position ( _text ; "&#" ; 1 ; 1 )__LITBR__ ; _pos2 = Position ( _text ; ";" ; _pos ; 1 ) - _pos__LITBR__ ; _word = Middle ( _text ; _pos ; _pos2 + 1 )__LITBR__ ; _isCode = Length ( _word ) >= 4 and Length ( _word ) <= 8 and Substitute ( _word ; [ 0 ; "" ] ; [ 1 ; "" ] ; [ 2 ; "" ] ; [ 3 ; "" ] ; [ 4 ; "" ] ; [ 5 ; "" ] ; [ 6 ; "" ] ; [ 7 ; "" ] ; [ 8 ; "" ] ; [ 9 ; "" ]) = "&#;"__LITBR__ ; _result = Left ( _text ; _pos - 1 ) & Case ( _isCode ; Char ( GetAsNumber ( _word )) ; "&" )__LITBR__];__LITBR___result & HTMLencoded2Text ( Right ( _text ; Length ( _text ) - ( _pos + Case ( _isCode ; Length ( _word ) - 1 ))))__LITBR__)__LITBR__))__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/178__LITBR____LITBR__ Prototype: HTMLencoded2Text( _text )__LITBR__ Function Author: Fabrice (http://www.fmfunctions.com/mid/37)__LITBR__ Last updated: 14 May 2009__LITBR__ Version: 3.2__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
03 May 2009
During an import, I found myself with those here who was not in your list
; [ "≤" ; "≤" ]
; [ "≥ " ; "≥" ]
; [ "¶" ; Citation ( "#|^|#¶#|^|#" ) ]
; [ "\"#|^|#" ; "" ]; [ "#|^|#\"" ; "" ]
; [ "“" ; "\"" ]
; [ "”" ; "\"" ]
in cazou
Thanks a lots for this one !
Agnès
(Edited by Agnès on 03/05/09 )