Functions needed to transcode texts into various character sets.
Transcoding functions turns binary strings encoded in a format into Falcon strings, or conversely, they turn Falcon strings into binary encoded buffers. Used in combination with binary stream reads and write, this function allows full internationalization of script input and output.
However, if the target stream is known to support safe reads and writes and to provide immediate access to the needed data, the Stream.setEncoding method is more efficient, as it doesn't need a temporary buffer to store the binary read data, or the binary data that has to be written.
Returns the "official" system encoding, if it matches with one known by Falcon.
getSystemEncoding()
Return | The system encoding name. |
This function will return the name under which Falcon knows the default system encoding. Using returned value, the program is able to create encoders that should be able to parse the data provided by system functions as directory scanning, or that is probably used as the main encoding for system related text files (i.e. configuration files).
Returns a Falcon string created by parsing the given one as a binary sequence of bytes.
transcodeFrom( string, encoding )
string | Falcon string or MemBuf to be encoded. | ||
encoding | Name of the encoding (as a string). | ||
Return | On success, the transcoded string. | ||
Raise |
|
In case the encoding name is not known, the function will raise a ParamError. The transcoding may also fail if the source data is not a valid sequence under the given encoding, and cannot be decoded.
Returns a binary buffer containing an encoded representation of a Falcon string.
transcodeTo( string, encoding )
string | Falcon string to be encoded. | ||
encoding | Name of the encoding (as a string). | ||
Return | On success, the transcoded string. | ||
Raise |
|
In case the encoding name is not known, the function will raise a ParamError.