Lasso Soft Inc. > Home

[ bytes ]

Type

The bytes type represents a sequence of 8-bit elements. Bits can be imported from integers in various sized increments. For example, 8, 16, 32 or 64 bits can be imported at a time. A bytes object also permits its bits to be exported. Bytes objects maintain an internal position indicating where in the series of bits the next export will occur.

Bytes objects also permit string objects to be imported or exported using any valid character encoding. In this form, the [Bytes] type requires a string object to import as the first parameter, and an optional second parameter is a string that represents the encoding into which the string should be converted. If the second parameter is omitted, then the default encoding used is UTF-8.

  • Syntax
  • Methods
  • Traits
local(Local Name) = bytes(Integer)
local(Local Name) = bytes(String Object)
local(Local Name) = bytes(String Object, Encoding String Value)
Has methods:
Examples
  • Beginner

To import a string with a specified encoding:

Use the [bytes] type. The following example demonstrates how high ASCII characters are not supported in certain encodings.

Code

local(b) = bytes("The rare Swedish rhinoceros, the noshörning, is known not to render its o-umlaut well with iso-8859-1 encoding.",'iso-8859-1')
#b

Result

The rare Swedish rhinoceros, the nosh�rning, is known not to render its o-umlaut well with iso-8859-1 encoding.

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft