Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5   13.0   13.1    Statistic    FMM    Blog  

Text.EncodeURLComponent

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)

Parameters

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

Result

Returns encoded string.

Description

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

Examples

Encode blog URL:

MBS("Text.EncodeURLComponent"; "http://www.mbsplugins.de")

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

Encode file name for FTP URL:

"ftp://monkeybreadsoftware.de/path/" & 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:
e%CC%81
%C3%A9
%E9
%8E

Mount with properly encoding french accent:

Set Variable [ $path; Value: MBS( "Files.Mount"; "afp://stockage.madabout.lu/" & 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

See also

Example Databases

Blog Entries

This function does not need a paid license.

Created 18th August 2014, last changed 31st January 2023


Text.EncodeToXML - Text.FileExtensionToMimeType

💬 Ask a question or report a problem


Start Chat