formatString

Syntax

string formatString(string s)

Arguments

s
A string containing 2-character formatting substrings and HTML entity codes

Return

Returns string s with substitutions made.

Description

Returns string s with the following substitutions made for the designated 2-character substrings (all of which begin with "!" or "&")

Overview

FM deals with 4 different escape characters, which are substituted in 3 separate phases:
  • escape character '\'
Escape code sequences beginning with '\' are handled by the parser, only during the parsing of string constants (not string variables). FM performs the usual C-language substitutions: '\t' for TAB, '\n' for new-line, '\r' for carriage-return, '\"' for a double-quote, etc.
The '\' char itself is represented by the escape code '\\'.
  • escape character '%'
Escape codes beginning with '%' are handled by the next phase, only during processing by built-in functions that take a variable number of arguments (such as setDialogTextv). FM calls the C-library routine sprintf (or some equivalent) which replaces the %-escape codes with formatted representations of the optional arguments according to the C-library conventions: "%d" for a decimal number argument, "%s" for a character string argument, etc.
The '%' char itself is represented by the escape code "%%".
  • escape characters '!' and '&'
Escape codes beginning with these characters are processed by the formatString routine during the final pass.
Two-character escape codes begining with '!' are substituted with an internal FM text string value: "!A" is replaced with the contents of the built-in string filterAuthorText (which contains the value of the Author: keyword field), "!C" is replaced by the contents of the filterCategoryText string, etc.
The '!' char itself is represented by the escape code "!!".
Escape codes beginning with '&' and ending with ';' are HTML entity references. FM replaces the escape code sequence """ with a double-quote character, "€" with the euro character, etc.
The '&' char itself is represented by the escape code "&&" or "&".
In summary, if your character string will be processed by any one of the above 3 passes, the escape character(s) for that pass can be represented by doubling the escape character in question. (If your string will NOT be processed by some particular pass, then the escape character(s) for that pass should NOT be doubled.)

! escape sequences

substring is replaced by
&& "&" (i.e., a verbatim ampersand)
!! "!" (i.e., a verbatim exclamation point)
!A text specified by the (Author)? key, obtained from the (filterAuthorText)? string
!a text specified by the (About)? key, obtained from the (filterAboutText)? string
!C text specified by the (Category)? key, obtained from the (filterCategoryText)? string
!c text specified by the (Copyright)? key, obtained from the (filterCopyrightText)? string
!D text specified by the (Description)? key, obtained from the (filterDescriptionText)? string
!d text specified by the (propTitle)? image property, obtained from the (documentTitleText)? string (not yet implemented)
!F text specified by the (Filename)? key, obtained from the (filterFilenameText)? string
!f the current Filter Case (e.g., "Flat image, no selection"), obtained from the (filterCaseText)? string
!H the name of the Host application (e.g., "Adobe Photoshop"), obtained from the (filterHostText)? string
!h the height of the image in pixels, obtained from the (imageHeight)? variable
!I the directory in which the plug-in filter was installed, from the filterInstallDir string (not yet implemented)
!M the current Image Mode (e.g., "RGB Color"), obtained from the (filterImageModeText)? string
!m the current image mode as a decimal integer, obtained from the imageMode variable
!O text specified by the (Organization)? key, obtained from the (filterOrganizationText)? string
!S the current host serial number string, obtained from the (hostSerialString)? string (not yet implemented)
!s the current host serial number as a decimal value, from the hostSerialNumber variable (not yet implemented)
!T text specified by the (Title)? key, obtained from the (filterTitleText)? string
!t text specified by the (Title)? key as above, with any trailing ellipsis removed
!U text specified by the (URL)? key, obtained from the (filterURLText)? string
!V text specified by the (Version)? key, obtained from the (filterVersionText)? string
!w the width of the image in pixels, obtained from the (imageWidth)? variable
!X the Host architecture of the host system running the plugin (either "32" for a 32-bit system or "64" for a 64-bit system) (implemented in FM mt5c05)
!x the Target architecture the plugin was compiled for (eg "32" for a 32-bit plugin, "64" for a 64-bit plugin) (implemented in FM mt5c05)
!Y the current year in decimal (e.g., for use in a Copyright message) (implemented in 1.0 Beta 9.0c)
!z the current proxy preview zoom factor (1 - 16), from the zoomFactor variable
Caution: Other substrings beginning with "!" are reserved for future use.

HTML entities

formatString also substitutes ISO character codes for the following HTML entity names.
Entity nameISOCharacter meaning
Common Punctuation
&quote; " double quote
& & ampersand
' ' apostrophe
… horizontal ellipsis
¿ ¿ inverted question mark
¡ ¡ inverted exclamation mark
&Exclam; !! double exclamation mark
§ § section mark
¶ paragraph mark
&pilcrow; pilcrow (unfilled paragaph mark)
• bullet
&bull2; bullet style 2
&ibull2; inverse bullet style 2
Currency and Commerce Symbols
¤ ¤ currency sign
¢ ¢ cent sign
£ £ pound sign
¥ ¥ Yen sign
€ Euro sign
© © copyright
® ® registered trademark
™ trademark
‰ per mille
¦ ¦ broken vertical bar
ª ª feminine ordinal
º º masculine ordinal
♂ male symbol
♀ female symbol
Science, Logic, and Mathematics Symbols
&lt; < less than
&gt; > greater than
&le; <= less or equal (substitute for &#8804;)
&ge; >= greater or equal (substitute for &#8805;)
&ne; != not equal (substitute for &#8800;)
&colone; := (used for colon-equal)
&Colon; :: (used for double colon)
&deg; ° degree sign
&prime; ' prime, minutes, feet
&Prime; " double prime, seconds, inches
&not; ¬ logical not
&plusmn; ± plus-or-minus sign
&minus; - minus sign (en-dash used as substitute)
&times; × multiplication symbol (times)
&divide; ÷ Division sign
&lowast; * low asterisk (asterisk used as substitute)
&sdot; · dot operator
&middot; · vertically centered dot
&empty; Ø Empty set
&sim; ~ similar to (tilde used as substitute)
&frac14; ¼ fraction 1/4
&frac12; ½ fraction 1/2
&frac34; ¾ fraction 3/4
&frasl; / fraction slash (use /)
&oline; ¯ overline (use macron)
&micro; µ micro
&fnof; ƒ f with hook
&image; I imaginary part (blackletter I)
&real; R real part (blackletter R)
&weierp; P Weierstrass powerset (script P)
Markup-significant and Internationalization Characters
&nbsp; non-breaking space
&shy; soft hyphen (never breaks in FM, so never displays)
&mdash; em dash
&ndash; en dash
&emsp; em-space (use normal space)
&ensp; en-space (use normal space)
&thinsp; thin space (use normal space)
&zwnj; zero width non-joiner (no char)
&zwj; zero width joiner (no char)
Spacing Accents, Diaereses and other Diacritical Marks
&acute; ´ acute accent
&uml; ¨ umlaut (diaeresis)
&cedil; ¸ spacing cedilla
&circ; ˆ modifier letter circumflex accent
&tilde; ˜ small tilde
&macr; ¯ spacing macron (overhead line)
Uppercase Accented Letters and Ligatures
&Agrave; À A grave
&Aacute; Á A acute
&Acirc; Â A circumflex
&Atilde; Ã A tilde
&Auml; Ä A umlaut
&Aring; Å A ring
&AElig; Æ A-E ligature
&Ccedil; Ç C cedilla
&Egrave; È E grave
&Eacute: É E acute
&Ecirc; Ê E circumflex
&Euml; Ë E umlaut
&Igrave; Ì I grave
&Iacute; Í I acute
&Icirc; Î I circumflex
&Iuml; Ï I umlaut
&Ntilde; Ñ N tilde
&Ograve; Ò O grave
&Oacute; Ó O acute
&Ocirc; Ô O circumflex
&Otilde; Õ O tilde
&Ouml; Ö O umlaut
&Oslash; Ø slashed O
&OElig; ΠO-E ligature
&Scaron; Š capital S with caron
&Ugrave; Ù U grave
&Uacute; Ú U acute
&Ucirc; Û U circumflex
&Uuml; Ü U umlaut
&Yacute; Ý Y acute
&Yuml; Ÿ capital Y with diaeresis
&Zcaron; Ž capital Z with caron (not official)
&ETH; Ð capital letter Eth
&THORN; Þ capital letter Thorn
Lowercase Accented Letters and Ligatures
&szlig; ß s-z ligature
&agrave; à a grave
&aacute; á a acute
&acirc; â a circumflex
&atilde; ã a tilde
&auml; ä a umlaut
&aring; å a ring
&aelig; æ a-e ligature
&ccedil; ç c cedilla
&egrave; è e grave
&eacute; é e acute
&ecirc; ê e circumflex
&euml; ë e umlaut
&igrave; ì i grave
&iacute; í i acute
&icirc; î i circumflex
&iuml; ï i umlaut
&ntilde; ñ n tilde
&ograve; ò o grave
&oacute; ó o acute
&ocirc; ô o circumflex
&otilde; õ o tilde
&ouml; ö o umlaut
&oslash; ø slashed o
&oelig; œ small o-e ligature
&scaron; š small s with caron
&ugrave; ù u grave
&uacute; ú u acute
&ucirc; û u circumflex
&uuml; ü u umlaut
&yacute; ý y acute
&yuml; ÿ y umlaut
&zcaron; ž small z with caron (not official)
&eth; ð small letter eth
&thorn; þ small letter thorn
Subscripts, Superscripts and Footnotes
&sup1; ¹ superscript 1
&sup2; ² superscript 2
&sup3; ³ superscript 3
&dagger; dagger
&Dagger; double dagger
Various Quotation Marks
&lsquo; left single quotation mark
&rsquo; right single quotation mark
&sbquo; single low-9 quotation mark
&bdquo; double low-9 quotation mark
&ldquo; left double quotation mark
&rdquo; right double quotation mark
&lsaquo; left single angle quotation
&rsaquo; right single angle quotation
&laquo; « left angle quote
&raquo; » right angle quote
Subset of Available Greek Characters
&Alpha; A Alpha (use latin capital A)
&Beta; B Beta (use latin capital B)
&Epsilon; E Epsilon (use latin capital E)
&Zeta; Z Zeta (use latin capital Z)
&Eta; H Eta (use latin capital H)
&Iota; I Iota (use latin capital I)
&Kappa; K Kappa (use latin capital K)
&Mu; M Mu (use latin capital M)
&Nu; N Nu (use latin capital N)
&Omicron; O Omicron (use latin capital O)
&Rho; P Rho (use latin capital P)
&Tau; T Tau (use latin capital T)
&Upsilon; Y Upsilon (use latin capital Y)
&Chi; X Chi (use latin capital X)
&beta; ß beta (use sz-ligature; yecch!)
&mu; µ mu (use &micro;)
&omicron; o omicron (use small latin o)
OEM Arrows, Line Drawing and Graphics
&larr; &#8592; leftwards arrow
&uarr; &#8593; upwards arrow
&rarr; &#8594; rightwards arrow
&crarr; carriage-return arrow (composed by two other graohics)
&varr; up/down (vertical) arrow (not official)
&ltrif; left-pointing triangle, filled
&blk14; lightly shaded box
&boxv; box drawing: vertical
&boxvl; box drawing: vertical and left
&boxdl; box drawing: down and left
&boxur; box drawing: up and right
&boxhu; box drawing: horizontal and up
&boxhd; box drawing: horizontal and down
&boxvr; box drawing: vertical and right
&boxh; box drawing: horizontal
&boxvh; box drawing: vertical and horizontal
&boxul; box drawing: up and left
&boxdr; box drawing: down and right
&twonotes; two beamed 16th notes

Notes

You do not usually need to call formatString() explicitly, since it is implicitly applied in the following cases:
- when displaying the text label for a dialog control,
- when displaying the items in a LISTBOX or COMBOBOX control,
- when displaying the dialog caption in the title bar,
- when displaying text in a Message Box via the msgBox(), printf(), Info(), Warn(), Error(), ErrorOk(), YesNo(), or YesNoCancel() built-in functions,
- when displaying the prompt in the chooseColor() color-picker dialog box,
- when specifying the registry path and key names in the Windows Systems Registry access functions,
- when displaying the About text in the About dialog box.

Example

For example, the default Dialog text is "!t (!M, !f)", which formatString() translates to something like "My Filter Title (RGB Color, Flat image, no selection)" at run time.

Also see

appendEllipsis, stripEllipsis

Comments

Everyone can add his comments about his experiences with this function here.
Tips for using it are welcome, too.