Utf8.escape: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(converted format list to table) |
||
Line 3: | Line 3: | ||
Escapes a string to a UTF-8 format string. It supports several escape formats: | Escapes a string to a UTF-8 format string. It supports several escape formats: | ||
{| class="prettytable" style="width:30%;" | |||
|- | |||
! Format || Description | |||
|- | |||
| '''%ddd''' || where ddd is a decimal number with variable length | |||
|- | |||
| '''%{ddd}''' || same as above, but enclosed in brackets | |||
|- | |||
| '''%uddd''' || same as '''%ddd''', 'u' stands for unicode | |||
|- | |||
| '''%u{ddd}''' || same as above, but enclosed in brackets | |||
|- | |||
| '''%xhhh''' || hexadigit version of '''%ddd''' | |||
|- | |||
| '''%x{hhh}''' || same as above, but enclosed in brackets | |||
|- | |||
| '''%?''' || where '?' stands for any other character to be escaped | |||
|} | |||
==Syntax== | ==Syntax== |
Revision as of 18:30, 15 February 2016
Escapes a string to a UTF-8 format string. It supports several escape formats:
Format | Description |
---|---|
%ddd | where ddd is a decimal number with variable length |
%{ddd} | same as above, but enclosed in brackets |
%uddd | same as %ddd, 'u' stands for unicode |
%u{ddd} | same as above, but enclosed in brackets |
%xhhh | hexadigit version of %ddd |
%x{hhh} | same as above, but enclosed in brackets |
%? | where '?' stands for any other character to be escaped |
Syntax
string utf8.escape ( string input )
Required Arguments
- input: A string character sequence
Returns
Returns a string containing the escaped UTF-8 characters from the original string.
Example
Click to collapse [-]
ServerThis example escapes two byte-string literals to UTF-8 format by using the utf8.escape function.
local output = utf8.escape( "%123 %u123 %{123} %u{123} %xABC %x{ABC}" ) print( output ) -- { { { { ઼ ઼ local output = utf8.escape( "%%123 %? %d %%u" ) print( output ) -- %123 ? d %u
See Also
Shared
- utf8.byte
- utf8.char
- utf8.charpos
- utf8.escape
- utf8.find
- utf8.fold
- utf8.gmatch
- utf8.gsub
- utf8.insert
- utf8.len
- utf8.lower
- utf8.match
- utf8.ncasecmp
- utf8.next
- utf8.remove
- utf8.reverse
- utf8.sub
- utf8.title
- utf8.upper
- utf8.width
- utf8.widthindex