qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcpie...@apache.org
Subject qpid-proton git commit: PROTON-736: Tweaked how Ruby 1.8 determines if a string is UTF-8
Date Tue, 02 Dec 2014 15:54:51 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master 39cd8c5dc -> e6c6873af


PROTON-736: Tweaked how Ruby 1.8 determines if a string is UTF-8

Uses the kconv stdlib module to add the "isutf8" method.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e6c6873a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e6c6873a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e6c6873a

Branch: refs/heads/master
Commit: e6c6873af7b83699ac94d8fe699beb51d1e2ef9d
Parents: 39cd8c5
Author: Darryl L. Pierce <mcpierce@gmail.com>
Authored: Tue Dec 2 09:25:17 2014 -0500
Committer: Darryl L. Pierce <mcpierce@gmail.com>
Committed: Tue Dec 2 10:54:09 2014 -0500

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/qpid_proton.rb         |  4 ++++
 proton-c/bindings/ruby/lib/qpid_proton/strings.rb | 12 ++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e6c6873a/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 0b7e77c..acd43ef 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -20,6 +20,10 @@
 require "cproton"
 require "date"
 
+if RUBY_VERSION < "1.9"
+require "kconv"
+end
+
 require "qpid_proton/version"
 require "qpid_proton/described"
 require "qpid_proton/strings"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e6c6873a/proton-c/bindings/ruby/lib/qpid_proton/strings.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton/strings.rb b/proton-c/bindings/ruby/lib/qpid_proton/strings.rb
index 44eba02..0b21886 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton/strings.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton/strings.rb
@@ -29,18 +29,14 @@ module Qpid # :nodoc:
       # No such thing in Ruby 1.8. So there we need to use Iconv to try and
       # convert it to unicode. If it works, good! But if it raises an
       # exception then we'll treat it as binary.
-      if RUBY_VERSION >= "1.9"
+      if RUBY_VERSION < "1.9"
+        return true if value.isutf8
+        return false
+      else
         return true if (value.encoding == "UTF-8" ||
                         value.encode("UTF-8").valid_encoding?)
 
         return false
-      else
-        begin
-          newval = Iconv.new("UTF8//TRANSLIT//IGNORE", "UTF8").iconv(value.to_s)
-          return true
-        rescue
-          return false
-        end
       end
     end
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message