kannel_rails 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -93,3 +93,10 @@ KannelRails.send_message("+639001234567", "Hello World!", :msg_id => '1234')
93
93
  ```
94
94
 
95
95
  This will result in Kannel calling something similar to the URL: `http://rails_app/some_endpoint?msg_id=1234&type=1&smsc_id=the_smsc_id`
96
+
97
+ ### Sending and receiving Unicode SMS
98
+
99
+ If your message text contains characters not in the [GSM charset](http://en.wikipedia.org/wiki/GSM_03.38), it will be automatically sent as Unicode by setting the param `coding=2`. Kannel should be able to handle this and send the message properly.
100
+
101
+ To receive Unicode SMS, just set `mo-recode = true` in your Kannel smsbox configuration so that everything the server receives will be in UTF-8.
102
+
@@ -1,3 +1,3 @@
1
1
  module KannelRails
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/kannel_rails.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require "kannel_rails/engine"
2
4
  require "kannel_rails/config"
3
5
  require "kannel_rails/handlers"
@@ -6,6 +8,9 @@ require "net/http"
6
8
 
7
9
  module KannelRails
8
10
 
11
+ GSM_7BIT = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà";
12
+ GSM_7BIT_EX = "^{}\[~]|€";
13
+
9
14
  def self.send_message(recipient, message, options = {})
10
15
  query_hash = {
11
16
  :username => config.username,
@@ -13,13 +18,18 @@ module KannelRails
13
18
  :to => recipient,
14
19
  :text => message,
15
20
  :'dlr-url' => config.dlr_url,
16
- :'dlr-mask' => config.dlr_mask
21
+ :'dlr-mask' => config.dlr_mask,
22
+ :charset => 'utf-8'
17
23
  }
18
24
 
19
25
  if config.dlr_url and options[:msg_id]
20
26
  query_hash[:'dlr-url'] = config.dlr_url.sub('$msg_id', options[:msg_id].to_s)
21
27
  end
22
28
 
29
+ if query_hash[:text] and !/\A[#{GSM_7BIT + GSM_7BIT_EX}]*\z/.match(query_hash[:text].to_s)
30
+ query_hash[:coding] = 2
31
+ end
32
+
23
33
  query_hash.merge!(options)
24
34
  query_hash.delete_if { |k, v| v.to_s.blank? }
25
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kannel_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-17 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails