utf8_converter 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/lib/utf8_converter.rb +4 -1
- data/lib/utf8_converter/version.rb +1 -1
- data/utf8_converter.gemspec +7 -2
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99375b1b16f5a26ed0ac89971f43f0ccab39bd77
|
4
|
+
data.tar.gz: 0023e13216c0a9dcec7c8a1233da6eaae5639185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65d29de66922e2d500fe7bca0dd3164fd0b720a55a3a9b6db312dff9a9cec2592b6441e469fd61bb3a441c4df8dfbc99ebb181714723c2fbb268629c009ea513
|
7
|
+
data.tar.gz: ad50942fdd4f842efb60636af0c8b3d032fdab834cc98469a48e904469d29347b39698e4dfcf4048469920a4ab6deb5ac27e3e0d22d217492a4c28b7e3040ffe
|
data/README.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# UTF8 Converter
|
2
2
|
|
3
|
-
A
|
3
|
+
A gem to force the convertion of text in any encoding into UTF8 without crashing and doing
|
4
|
+
the best guess convertion.
|
5
|
+
|
6
|
+
## Description
|
7
|
+
|
8
|
+
This gem attempts to convert the received text to UTF8. It works by trying to convert
|
9
|
+
the given text with a list of possible common encodings. This is useful if the developer
|
10
|
+
knows the most common encodings that the application is going to be receiving, leaving
|
11
|
+
the guessing work to this gem and by safely converting (without crashing) the received text.
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
@@ -38,7 +46,8 @@ puts unknown_text
|
|
38
46
|
|
39
47
|
```
|
40
48
|
|
41
|
-
However the previous code will only convert the encodings listed
|
49
|
+
However the previous code will only convert the encodings listed the default commong
|
50
|
+
encodings variable:
|
42
51
|
in the following variable:
|
43
52
|
|
44
53
|
```
|
@@ -67,3 +76,12 @@ UTF8Converter.default_replace_character = ''
|
|
67
76
|
puts "A\xF1o".to_utf8
|
68
77
|
# Ao
|
69
78
|
```
|
79
|
+
|
80
|
+
Binary data will be safely converted to UTF8 with loss, because there are characters in the binary
|
81
|
+
8 bit ASCII that are not convertible to UTF8. However, the convertion will not fail.
|
82
|
+
|
83
|
+
```
|
84
|
+
text = "\xA9".force_encoding(Encoding::BINARY)
|
85
|
+
puts text.to_utf8
|
86
|
+
# ©
|
87
|
+
```
|
data/lib/utf8_converter.rb
CHANGED
@@ -35,7 +35,10 @@ class UTF8Converter
|
|
35
35
|
@common_encodings.each do |encoding|
|
36
36
|
return string if try_convert_from_encoding_to_utf8!(string, encoding)
|
37
37
|
end
|
38
|
-
string.encode!(Encoding::UTF_8,
|
38
|
+
string.encode!(Encoding::UTF_8,
|
39
|
+
invalid: :replace,
|
40
|
+
undef: :replace,
|
41
|
+
replace: @default_replace_character)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
data/utf8_converter.gemspec
CHANGED
@@ -9,8 +9,13 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Jorge Del Rio']
|
10
10
|
spec.email = ['jdelrios@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = 'A gem to force
|
13
|
-
|
12
|
+
spec.summary = 'A gem to force the convertion of text in any encoding into UTF8 without' +
|
13
|
+
' crashing and doing the best guess convertion'
|
14
|
+
spec.description = 'This gem attempts to convert the received text to UTF8. It works by trying to' +
|
15
|
+
' convert the given text with a list of possible common encodings. This is' +
|
16
|
+
' useful if the developer knows the most common encodings that the application' +
|
17
|
+
' is going to be receiving, leaving the guessing work to this gem and by safely' +
|
18
|
+
' converting (without crash) the received text.'
|
14
19
|
spec.homepage = 'https://github.com/newint33h/utf8_converter.git'
|
15
20
|
spec.license = 'MIT'
|
16
21
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utf8_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Del Rio
|
@@ -52,7 +52,11 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5'
|
55
|
-
description: This gem attempts to convert
|
55
|
+
description: This gem attempts to convert the received text to UTF8. It works by trying
|
56
|
+
to convert the given text with a list of possible common encodings. This is useful
|
57
|
+
if the developer knows the most common encodings that the application is going to
|
58
|
+
be receiving, leaving the guessing work to this gem and by safely converting (without
|
59
|
+
crash) the received text.
|
56
60
|
email:
|
57
61
|
- jdelrios@gmail.com
|
58
62
|
executables: []
|
@@ -89,5 +93,6 @@ rubyforge_project:
|
|
89
93
|
rubygems_version: 2.5.1
|
90
94
|
signing_key:
|
91
95
|
specification_version: 4
|
92
|
-
summary: A gem to force
|
96
|
+
summary: A gem to force the convertion of text in any encoding into UTF8 without crashing
|
97
|
+
and doing the best guess convertion
|
93
98
|
test_files: []
|