File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
EncodedString is a wrapper for a string and a given encoding that handles operations on
4
4
strings with different encodings, invalid encodings, have no known conversion method,
5
- or are otherwise incompatible, all without raising excpetions
5
+ or are otherwise incompatible, all without raising exceptions
6
6
7
7
## Installation
8
8
@@ -22,10 +22,16 @@ Or install it yourself as:
22
22
23
23
## Usage
24
24
25
+ Pick compatible encoding for two strings, if any:
26
+
25
27
``` ruby
26
28
EncodedString .pick_encoding(str1, str2)
29
+ ```
27
30
28
- string = " 123" .force_encoding(EncodedString ::UTF_8 )
31
+ Wrap a string and make it safely accomodate the target encoding:
32
+
33
+ ``` ruby
34
+ string = " 123" .force_encoding(Encoding ::UTF_8 )
29
35
str = " abc" .encode(' ASCII-8BIT' )
30
36
str = EncodedString .new (str, target_encoding = string.encoding)
31
37
str.source_encoding.to_s
You can’t perform that action at this time.
0 commit comments