mail-iso-2022-jp 1.1.2 → 1.1.4
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.
- data/README.md +7 -3
- data/lib/mail-iso-2022-jp/patches.rb +18 -9
- metadata +26 -50
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Feature
|
|
22
22
|
|
23
23
|
If you set the `charset` header to `ISO-2022-JP`, the values of `From`, `Sender`, `To`, `Cc`,
|
24
24
|
`Reply-To`, `Subject`, `Resent-From`, `Resent-Sender`, `Resent-To` and `Resent-Cc` headers
|
25
|
-
and the text of body will be automatically converted to `ISO-2022-JP
|
25
|
+
and the text of body will be automatically converted to `ISO-2022-JP`.
|
26
26
|
|
27
27
|
When the `charset` header has other values, this patch has no effect.
|
28
28
|
|
@@ -30,7 +30,7 @@ Feature
|
|
30
30
|
|
31
31
|
chasetヘッダの値が `ISO-2022-JP` である場合、差出人(From)、Sender、宛先(To)、Cc、Reply-To、件名(Subject)、
|
32
32
|
Resent-From、Resent-Sender、Resent-To、Resent-Cc の各ヘッダの値および本文(Body)が
|
33
|
-
|
33
|
+
自動的に `ISO-2022-JP` に変換されます。
|
34
34
|
|
35
35
|
charsetヘッダの値が `ISO-2022-JP` でない場合、このパッチには何の効果もありません。
|
36
36
|
|
@@ -46,6 +46,10 @@ Requirements
|
|
46
46
|
|
47
47
|
* `mail` 2.2.5 or higher
|
48
48
|
|
49
|
+
### Ruby on Rails (Optional) ###
|
50
|
+
|
51
|
+
* 3.0 or higher
|
52
|
+
|
49
53
|
|
50
54
|
Getting Start
|
51
55
|
-------------
|
@@ -107,7 +111,7 @@ Remarks
|
|
107
111
|
-------
|
108
112
|
|
109
113
|
* `①` などのNEC特殊文字や `髙` や `﨑` といったIBM拡張文字を件名、宛先、本文などに含めることができます。
|
110
|
-
*
|
114
|
+
* 全角チルダ(U+FF5E)は波ダッシュ(U+301C)に変換されます。
|
111
115
|
* 半角カタカナはそのまま維持されます。
|
112
116
|
|
113
117
|
|
@@ -6,12 +6,13 @@ require 'base64'
|
|
6
6
|
module Mail
|
7
7
|
WAVE_DASH = "〜" # U+301C
|
8
8
|
FULLWIDTH_TILDE = "~" # U+FF5E
|
9
|
-
NKF_OPTIONS = "--oc=CP50220 -xj"
|
10
9
|
if RUBY_VERSION >= '1.9'
|
11
10
|
ENCODE = {'iso-2022-jp' => Encoding::CP50221}
|
12
11
|
def self.encoding_to_charset(str, charset)
|
13
12
|
str.encode(ENCODE[charset.to_s.downcase] || charset).force_encoding(charset)
|
14
13
|
end
|
14
|
+
else
|
15
|
+
NKF_OPTIONS = "--oc=CP50220 -xj"
|
15
16
|
end
|
16
17
|
|
17
18
|
class Message
|
@@ -51,15 +52,10 @@ module Mail
|
|
51
52
|
|
52
53
|
def initialize_with_iso_2022_jp_encoding(value = nil, charset = 'utf-8')
|
53
54
|
if charset.to_s.downcase == 'iso-2022-jp'
|
54
|
-
|
55
|
-
|
56
|
-
value = Mail.encoding_to_charset(value, charset)
|
57
|
-
value.force_encoding('ascii-8bit')
|
58
|
-
value = b_value_encode(value)
|
59
|
-
value.force_encoding('ascii-8bit')
|
55
|
+
if value.kind_of?(Array)
|
56
|
+
value = value.map { |e| encode_with_iso_2022_jp(e, charset) }
|
60
57
|
else
|
61
|
-
value =
|
62
|
-
value = b_value_encode(value)
|
58
|
+
value = encode_with_iso_2022_jp(value, charset)
|
63
59
|
end
|
64
60
|
end
|
65
61
|
initialize_without_iso_2022_jp_encoding(value, charset)
|
@@ -73,6 +69,19 @@ module Mail
|
|
73
69
|
do_decode_without_iso_2022_jp_encoding
|
74
70
|
end
|
75
71
|
end
|
72
|
+
|
73
|
+
def encode_with_iso_2022_jp(value, charset)
|
74
|
+
value = value.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
|
75
|
+
if RUBY_VERSION >= '1.9'
|
76
|
+
value = Mail.encoding_to_charset(value, charset)
|
77
|
+
value.force_encoding('ascii-8bit')
|
78
|
+
value = b_value_encode(value)
|
79
|
+
value.force_encoding('ascii-8bit')
|
80
|
+
else
|
81
|
+
value = NKF.nkf(NKF_OPTIONS, value)
|
82
|
+
b_value_encode(value)
|
83
|
+
end
|
84
|
+
end
|
76
85
|
|
77
86
|
def b_value_encode(string)
|
78
87
|
string.split(' ').map do |s|
|
metadata
CHANGED
@@ -1,85 +1,61 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-iso-2022-jp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 2
|
10
|
-
version: 1.1.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Kohei MATSUSHITA
|
14
9
|
- Tsutomu KURODA
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2011-12-07 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: mail
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &12325840 !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 2
|
33
|
-
- 5
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
34
22
|
version: 2.2.5
|
35
23
|
type: :runtime
|
36
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *12325840
|
37
26
|
description: A patch that provides 'mail' gem with iso-2022-jp conversion capability.
|
38
27
|
email: hermes@oiax.jp
|
39
28
|
executables: []
|
40
|
-
|
41
29
|
extensions: []
|
42
|
-
|
43
30
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
31
|
+
files:
|
46
32
|
- README.md
|
47
33
|
- Gemfile
|
48
34
|
- Rakefile
|
49
|
-
- lib/mail-iso-2022-jp.rb
|
50
35
|
- lib/mail-iso-2022-jp/patches.rb
|
36
|
+
- lib/mail-iso-2022-jp.rb
|
51
37
|
homepage: http://github.com/kuroda/mail-iso-2022-jp
|
52
38
|
licenses: []
|
53
|
-
|
54
39
|
post_install_message:
|
55
40
|
rdoc_options: []
|
56
|
-
|
57
|
-
require_paths:
|
41
|
+
require_paths:
|
58
42
|
- lib
|
59
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
44
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
|
66
|
-
- 0
|
67
|
-
version: "0"
|
68
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
50
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
77
55
|
requirements: []
|
78
|
-
|
79
56
|
rubyforge_project:
|
80
57
|
rubygems_version: 1.8.10
|
81
58
|
signing_key:
|
82
59
|
specification_version: 3
|
83
60
|
summary: A patch that provides 'mail' gem with iso-2022-jp conversion capability.
|
84
61
|
test_files: []
|
85
|
-
|