![]() Its associated encoding is also set to the other encoding. translate its internal byte representation to another encoding. Second, it is possible to transcode a string, i.e. ![]() This is how you can tell Ruby the correct encoding of a string. The associated Encoding of a String can be changed in two different ways.įirst, it is possible to set the Encoding of a string to a new Encoding without changing the internal byte representation of the string, with String#force_encoding. This is useful when you use ASCII-8BIT characters with other ASCII compatible characters. But as the name insists, its characters in the range of ASCII are considered as ASCII characters. encode "ISO-8859-1" #=> "some string"Įncoding::ASCII_8BIT is a special encoding that is usually used for a byte string, not a character string. ![]() Ruby methods dealing with encodings return or accept Encoding instances as arguments (when a method accepts an Encoding instance as an argument, it can be passed an Encoding name or alias instead). It has a name and optionally, aliases: Encoding :: ISO_8859_1. It is defined as a constant under the Encoding namespace. An Encoding instance represents a character encoding usable in Ruby.
0 Comments
Leave a Reply. |