Module: Qpid::Proton::Types
- Defined in:
- lib/types/described.rb,
lib/types/strings.rb,
lib/types/array.rb
Overview
– Patch the Array class to provide methods for adding its contents to a Qpid::Proton::Data instance. ++
Defined Under Namespace
Classes: ArrayHeader, BinaryString, Described, UTFString
Class Method Summary collapse
Class Method Details
.is_valid_utf?(value) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/types/strings.rb', line 23 def self.is_valid_utf?(value) # In Ruby 1.9+ we have encoding methods that can check the content of # the string, so use them to see if what we have is unicode. If so, # good! If not, then just treat is as binary. # # 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" return true if value.isutf8 return false else return true if (value.encoding == "UTF-8" || value.encode("UTF-8").valid_encoding?) return false end end |