GOLF(2gg)

NAME
text-utf - (UTF)

PURPOSE
Convert text to UTF (UTF8 or UTF16) string.

SYNTAX

        text-utf <text> \
            [ status <status> ] \
            [ error-text <error text> ]

DESCRIPTION
text-utf will convert string value <text> to UTF. <text> itself will hold the resulting UTF string. If you don't wish <text> to be modified, make a copy of it first (see copy-string). See utf-text for the reverse conversion and data standards information.

You can obtain <status> in "status" clause. <status> number is GG_OKAY if successful, or GG_ERR_UTF if there was an error, in which case <error text> string in "error-text" clause will contain the error message.

EXAMPLES

        // Unicode value to encode to UTF8 or UTF16 (such as \euD834\euDD1E as a surrogate pair)
        set-string txt = "\u0459\\"Doc\\"\en\et\eb\ef\er\et\eu21d7\eu21d8\et\eu25b7\eu25ee\euD834\euDD1E\eu13eb\eu2ca0\eu0448\en\e/\\"()\et"

        // Convert to UTF
        text-utf txt status txt_status error-text txt_error

        // Expected UTF result
        set-string utf = "љ\"Doc\"\n\t\b\f\r\t⇗⇘\t▷◮𝄞ᏫⲠш\n/\"()\t"

        // Make sure conversion was successful
        if-true utf not-equal txt or txt_status not-equal GG_OKAY or txt_error not-equal ""
            @Error in converting string to UTF
        end-if

SEE ALSO
 UTF

text-utf utf-text See all documentation