mail-iso-2022-jp 2.0.0.pre3 → 2.0.0

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 CHANGED
@@ -118,19 +118,19 @@ Remarks
118
118
  * (en)
119
119
  * NEC special characters like `①` and IBM extended characters like `髙`, `﨑`
120
120
  are allowed in the subject, recipient names and mail body.
121
- * FULLWIDTH TILDE (U+FF5E) and WAVE DASH (U+301C) are converted to the fullwidth tilde `〜` (0x2141).
122
- * FULLWIDTH HYPHEN MINUS (U+FF0D) and MINUS SIGN (U+2212) are converted to the fullwidth minus `−` (0x215d).
123
- * EM DASH (U+2014) and HORIZONTAL BAR (U+2015) are converted to the dash sign `—` (0x213d).
124
- * DOUBLE VERTICAL LINE (U+2016, '‖') and PARALLEL TO (U+2225, `∥`) to `‖` (0x2142).
121
+ * FULLWIDTH TILDE (U+FF5E) and WAVE DASH (U+301C, `〜`) are converted to the fullwidth tilde (0x2141, `〜`).
122
+ * FULLWIDTH HYPHEN MINUS (U+FF0D) and MINUS SIGN (U+2212) are converted to the fullwidth minus (0x215d, `-`).
123
+ * EM DASH (U+2014) and HORIZONTAL BAR (U+2015) are converted to the dash sign (0x213d, `―`).
124
+ * DOUBLE VERTICAL LINE (U+2016, `‖`) and PARALLEL TO (U+2225, `∥`) to the double vertical line (0x2142, `‖`).
125
125
  * Halfwidth (Hankaku) katakanas are maintained intact.
126
126
  * Characters that cannot be translated into iso-2022-jp encoding are substituted with question marks (`?`).
127
127
 
128
128
  * (ja)
129
129
  * `①` などのNEC特殊文字や `髙` や `﨑` といったIBM拡張文字を件名、宛先、本文などに含めることができます。
130
- * 全角チルダ(U+FF5E)と波ダッシュ(U+301C)は、全角チルダ(2141)に変換されます。
131
- * 全角ハイフンマイナス(U+ff0D)とマイナス記号(U+2212)は、全角マイナス(215D)に変換されます。
132
- * 長い(em)ダッシュ(U+2014)と水平線(U+2015)は、ダッシュ(213D)に変換されます。
133
- * 二重縦線(U+2016, '‖')と平行記号(U+2225, `∥`)は、`‖` (0x2142)に変換されます。
130
+ * 全角チルダ(U+FF5E, `~`)と波ダッシュ(U+301C, `〜`)は、全角チルダ(0x2141, `~`)に変換されます。
131
+ * 全角ハイフンマイナス(U+ff0D)とマイナス記号(U+2212)は、全角マイナス(0x215d, `-`)に変換されます。
132
+ * 長い(em)ダッシュ(U+2014, `—`)と水平線(U+2015, `―`)は、ダッシュ(0x213d, `―`)に変換されます。
133
+ * 二重縦線(U+2016, `‖`)と平行記号(U+2225, `∥`)は、二重縦線(0x2142, `‖`)に変換されます。
134
134
  * 半角カタカナはそのまま維持されます。
135
135
  * 変換できない文字は疑問符(`?`)で置換されます。
136
136
 
@@ -142,6 +142,7 @@ References
142
142
  * http://d.hatena.ne.jp/hichiriki/20101026#1288107706
143
143
  * http://d.hatena.ne.jp/deeeki/20111003/rails3_mailer_iso2022jp
144
144
  * http://d.hatena.ne.jp/tmtms/20090611/1244724573
145
+ * Wikipedia [Unicode - 波ダッシュ・全角チルダ問題](http://ja.wikipedia.org/wiki/Unicode#.E6.B3.A2.E3.83.80.E3.83.83.E3.82.B7.E3.83.A5.E3.83.BB.E5.85.A8.E8.A7.92.E3.83.81.E3.83.AB.E3.83.80.E5.95.8F.E9.A1.8C)
145
146
 
146
147
  License
147
148
  -------
@@ -1,6 +1,7 @@
1
1
  require 'mail-iso-2022-jp/character_names'
2
2
  require 'mail-iso-2022-jp/invalid_encoding_error'
3
3
  require 'mail-iso-2022-jp/common_methods_for_field'
4
+ require 'mail-iso-2022-jp/preprocessor'
4
5
 
5
6
  if RUBY_VERSION >= '1.9'
6
7
  require 'mail-iso-2022-jp/mail'
@@ -26,7 +26,7 @@ module Mail
26
26
 
27
27
  private
28
28
  def encode_with_iso_2022_jp(value, charset)
29
- value = preprocess(value)
29
+ value = Mail::Preprocessor.process(value)
30
30
  value = Mail.encoding_to_charset(value, charset)
31
31
  value.force_encoding('ascii-8bit')
32
32
  value = b_value_encode(value)
@@ -11,9 +11,7 @@ module Mail
11
11
  raise ::Mail::InvalidEncodingError.new(
12
12
  "The mail body is not encoded in UTF-8 but in #{value.encoding}")
13
13
  end
14
- value = value.gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS)
15
- value = value.gsub(/#{EM_DASH}/, HORIZONTAL_BAR)
16
- value = value.gsub(/#{DOUBLE_VERTICAL_LINE}/, PARALLEL_TO)
14
+ value = Mail::Preprocessor.process(value)
17
15
  end
18
16
  self.body_without_iso_2022_jp_encoding = value
19
17
  end
@@ -22,7 +20,6 @@ module Mail
22
20
 
23
21
  def process_body_raw_with_iso_2022_jp_encoding
24
22
  if @charset.to_s.downcase == 'iso-2022-jp'
25
- @body_raw = @body_raw.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
26
23
  @body_raw = Mail.encoding_to_charset(@body_raw, @charset)
27
24
  end
28
25
  process_body_raw_without_iso_2022_jp_encoding
@@ -0,0 +1,11 @@
1
+ module Mail
2
+ class Preprocessor
3
+ def self.process(value)
4
+ value.to_s.
5
+ gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE).
6
+ gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS).
7
+ gsub(/#{EM_DASH}/, HORIZONTAL_BAR).
8
+ gsub(/#{DOUBLE_VERTICAL_LINE}/, PARALLEL_TO)
9
+ end
10
+ end
11
+ end
@@ -33,7 +33,7 @@ module Mail
33
33
  end
34
34
 
35
35
  def encode_with_iso_2022_jp(value)
36
- value = preprocess(value)
36
+ value = Mail::Preprocessor.process(value)
37
37
  value = NKF.nkf(NKF_OPTIONS, value)
38
38
  b_value_encode(value)
39
39
  end
@@ -12,10 +12,7 @@ module Mail
12
12
 
13
13
  def process_body_raw_with_iso_2022_jp_encoding
14
14
  if @charset.to_s.downcase == 'iso-2022-jp'
15
- @body_raw = @body_raw.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
16
- @body_raw = @body_raw.to_s.gsub(/#{MINUS_SIGN}/, FULLWIDTH_HYPHEN_MINUS)
17
- @body_raw = @body_raw.to_s.gsub(/#{EM_DASH}/, HORIZONTAL_BAR)
18
- @body_raw = @body_raw.to_s.gsub(/#{DOUBLE_VERTICAL_LINE}/, PARALLEL_TO)
15
+ @body_raw = Mail::Preprocessor.process(@body_raw)
19
16
  @body_raw = NKF.nkf(NKF_OPTIONS, @body_raw)
20
17
  end
21
18
  process_body_raw_without_iso_2022_jp_encoding
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-iso-2022-jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre3
5
- prerelease: 6
4
+ version: 2.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kohei MATSUSHITA
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-02 00:00:00.000000000 Z
13
+ date: 2013-01-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mail
@@ -87,6 +87,7 @@ files:
87
87
  - lib/mail-iso-2022-jp/subject_field.rb
88
88
  - lib/mail-iso-2022-jp/structured_fields.rb
89
89
  - lib/mail-iso-2022-jp/character_names.rb
90
+ - lib/mail-iso-2022-jp/preprocessor.rb
90
91
  - lib/mail-iso-2022-jp/header.rb
91
92
  - lib/mail-iso-2022-jp/invalid_encoding_error.rb
92
93
  - lib/mail-iso-2022-jp/mail.rb
@@ -106,12 +107,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  none: false
108
109
  requirements:
109
- - - ! '>'
110
+ - - ! '>='
110
111
  - !ruby/object:Gem::Version
111
- version: 1.3.1
112
+ version: '0'
112
113
  requirements: []
113
114
  rubyforge_project:
114
- rubygems_version: 1.8.23
115
+ rubygems_version: 1.8.24
115
116
  signing_key:
116
117
  specification_version: 3
117
118
  summary: A set of patches that provides 'mail' gem with iso-2022-jp conversion capability.