Spec-Zone.ru › ColdFusion

urlEncode

Returns an url-encoded string with respect to charset.

urlEncode(string [, charset] [, force]) → returns string

Member Function Syntax

string.urlEncode([charset] [, force])

This function requires Lucee. Not supported on Adobe ColdFusion, etc.
  • Lucee
  • See Also: encodeForURL urlDecode

    Argument Reference

    string string
    Required

    charset string
    Default: utf-8

    The character encoding in which the string will be encoded.
    Values:
    • utf-8
    • iso-8859-1
    • windows-1252
    • us-ascii
    • shift_jis
    • iso-2022-jp
    • euc-jp
    • euc-kr
    • big5
    • euc-cn
    • utf-16

    force boolean
    Default: true

    Examples
    Sample code invoking the urlEncode function

    String encoding

    Encode string with special chars for use in url

    urlEncode('Apples → Äpfel','utf-8')

    Expected Result: Apples+%E2%86%92+%C3%84pfel

    String charset

    Same string, different charset

    urlEncode('Apples → Äpfel','ASCII')

    Expected Result: Apples+%3F+%3Fpfel

    Convert collection to be able to be passed as url param value

    vocab = [{
            apples: {
                en: 'apples',
                de: 'Äpfel',
                da: 'æble',
                el: 'μήλο'
            }
        }];
        writeOutput(urlEncode(vocab.toString(),'utf-8'));

    Expected Result: %5B%7BAPPLES%3D%7B%7BEL%3D%7B%CE%BC%CE%AE%CE%BB%CE%BF%7D%2C+EN%3D%7Bapples%7D%2C+DA%3D%7B%C3%A6ble%7D%2C+DE%3D%7B%C3%84pfel%7D%7D%7D%7D%5D

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/urlencode

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API