Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Encodes an URL component.

Component Version macOS Windows Linux Server iOS SDK
Text 3.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Text.EncodeURLComponent"; text { ; encoding } )   More

(old name: String.EncodeURLComponent)


Parameter Description Example Flags
text The text to encode. $URL
encoding The text encoding for text parameter.
Default is native.
Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ.
"UTF-8" Optional


Returns encoded string.


Encodes an URL component.
Please check what text encoding you want to use. Especially what the software processing the hex string expects.


Encode blog URL:

MBS("Text.EncodeURLComponent"; "")

Example result: "http%3A%2F%2Fwww%2Embsplugins%2Ede"

Encode file name for FTP URL:

"" & MBS("Text.EncodeURLComponent"; $filename; "UTF-8")

Encode é in various encodings as URL:

MBS( "Text.EncodeURLComponent"; MBS( "Text.ConvertUnicodeToCharacterDecomposition"; "é" ); "UTF-8" ) & ¶ &
MBS( "Text.EncodeURLComponent"; MBS( "Text.ConvertUnicodeToCharacterComposition"; "é" ); "UTF-8" ) & ¶ &
MBS( "Text.EncodeURLComponent"; "é"; "Windows" ) & ¶ &
MBS( "Text.EncodeURLComponent"; "é"; "Mac" )

Example result:

Mount with properly encoding french accent:

Set Variable [ $path; Value: MBS( "Files.Mount"; "afp://" & MBS( "Text.EncodeURLComponent"; MBS( "Text.ConvertUnicodeToCharacterDecomposition"; "Travail archivé" )); "UTF-8" )) ]

# URL is "afp://test.myserver.local/Travail%20archiv%8E"

Encode emoji:

MBS( "Text.EncodeURLComponent"; "🍎 🍓 🍒"; "UTF-8" )

Example result: %F0%9F%8D%8E%20%F0%9F%8D%93%20%F0%9F%8D%92

Enocode file name for SFTP upload:

Set Variable [$EncodedFileName; Value: MBS( "Text.EncodeURLComponent"; $FileName; "utf-8" ) ]
Set Variable [$result; Value: MBS("CURL.SetOptionURL"; $curl; "ftps://" & $EncodedFileName )]

See also

Example Databases

Blog Entries

This function is free to use.

Created 18th August 2014, last changed 30th April 2024

Text.EncodeToXML - Text.FileExtensionToMimeType