utf8_converter 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 731755377192fe051e2d39ac746b0fa5d072727f
4
- data.tar.gz: a0e77a244a4f1ee80c7358b8f62fdf0be14a1822
3
+ metadata.gz: 99375b1b16f5a26ed0ac89971f43f0ccab39bd77
4
+ data.tar.gz: 0023e13216c0a9dcec7c8a1233da6eaae5639185
5
5
  SHA512:
6
- metadata.gz: a18279072b7d850addfe33ed2ac6389c98261bfe6fbf7548ece399e23023f55bcbcae0f4401d51499efad80963e891a568677aa22c9a8314a2299c457b51d8db
7
- data.tar.gz: f364e576ebb24eb8dfa187b17de34bba37cfc4314258201131b07885b3e97fe19ebd16183af6d0923bee132bd2869e782ec04961927e711c6e4a69acf4f1747e
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 Ruby gem that attempts to convert texts from unknown encodings to UTF8.
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 in the default 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
+ ```
@@ -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, invalid: :replace, replace: @default_replace_character)
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
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This partial class defines the version of the gem
4
4
  class UTF8Converter
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
@@ -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 all kind of text into UTF8 encoding'
13
- spec.description = 'This gem attempts to convert texts from unknown encodings to UTF8'
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.0
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 texts from unknown encodings to UTF8
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 all kind of text into UTF8 encoding
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: []