GOLF(2gg)

๐Ÿ“ฆ version 601.4.41, in ubuntu questing

๐Ÿ’– GOLF(2gg) ๐Ÿ’–

okay bestie, welcome to the 2gg manual section, we're doing GOLF today and honestly? it's giving โœจreference materialโœจ


๐ŸŒธ NAME ๐ŸŒธ

text-utf โ€” the (UTF) one ๐Ÿฆ‹


๐ŸŽ€ PURPOSE ๐ŸŽ€

Convert text to a UTF (UTF8 or UTF16) string. no cap, that's the whole job ๐Ÿ’…


โœจ SYNTAX โœจ

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

look at her, so clean, so demure ๐Ÿซถ


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

so like, text-utf takes that string value <text> and converts it to UTF. and here's the thing โ€” <text> itself will hold the resulting UTF string. like she's doing a little makeover on the spot, in place, no returns.

โš ๏ธ if you don't wish <text> to be modified, make a copy of it first (see copy-string). protect your original bestie, she's precious ๐Ÿ™ˆ

also, for the reverse conversion AND the data standards info, go peek at utf-text. they're a duo ๐Ÿ’ž

so about <status> โ€” you can obtain it in the status clause. the <status> number is GG_OKAY if successful, or GG_ERR_UTF if there was an error. and in that error case, the <error text> string in the error-text clause will contain the error message. very much "we'll tell you what went wrong" energy ๐Ÿ˜ญ


๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

okay so first, the Unicode value we're encoding to UTF8 or UTF16 (such as \euD834\euDD1E as a surrogate pair, iykyk):

// 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"

now convert it to UTF:

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

and here's the expected UTF result, look at her go ๐Ÿ˜:

// Expected UTF result
set-string utf = "ั™\"Doc\"\n\t\b\f\r\tโ‡—โ‡˜\tโ–ทโ—ฎ๐„žแซโฒ ัˆ\n/\"()\t"

and finally, make sure the conversion was actually successful, because we do NOT skip the vibe check:

// 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

ate. no crumbs. ๐Ÿ‘‘


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • UTF
  • text-utf
  • utf-text

and yesss, See all documentation for the full lore ๐Ÿ“š


okay that's the whole page bestie, you're officially fluent ๐Ÿ’–

this icon of a page came from the $VERSION era, dated $DATE, and it lives in the GOLF(2gg) family โ€” slay, periodt ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from