Revision Difference
string.char#528497
<function name="char" parent="string" type="libraryfunc">
<description>Takes the given numerical bytes and converts them to a string.</description>
<realm>Shared and Menu</realm>
<args>
<arg name="bytes" type="vararg">The bytes to create the string from.</arg>
</args>
<rets>
<ret name="" type="string">String built from given bytes</ret>
</rets>
</function>
<example>
<description>Prints a string consisting of the bytes 72, 101, 108, 108, 111</description>
<code>print( string.char( 72, 101, 108, 108, 111 ) )</code>
<outputfixedwidth>Fixed width</outputfixedwidth>⤶
<output>Hello</output>⤶
<output>⤶
```⤶
Hello⤶
```⤶
</output>⤶
</example>
<example>
<description>Helper function to create a random string.</description>
<code>
function string.Random( length )
local length = tonumber( length )
if length < 1 then return end
local result = "" -- The empty string we start with
for i = 1, length do
result = result .. string.char( math.random(32, 126) )
end
return result
end
print( string.Random( 10 ) )
</code>
<outputfixedwidth>Fixed width</outputfixedwidth>⤶
<output>oEjkv2?h:T</output>⤶
<output>⤶
```⤶
oEjkv2?h:T⤶
```⤶
</output>⤶
</example>