# textencode()

/require textencode.tf

Function usage:

textencode(string)
textdecode(encodedstring)

textencode converts string to a form that contains only letters, digits, and underscores. textdecode converts encodedstring (returned by a previous call to textencode) back to the original string.

These two functions can be useful for converting arbitrary text, such as a world name or the name of a player on a mud, into a form that is safe to use as part of a tf variable or macro name, or a filename.

The following example records the time a player connects to the mud, and is safe even if the player name contains characters that are not legal in tf variable names:
`/def -mglob -t'{*} has connected.' record_connect_time = \
/set connect_time_$[textencode({1})]=$[time()]`

See: functions

Back to index
Back to tf home page

Copyright © 2003, 2004 Ken Keys