Module: Qpid::Proton::Types

Defined in:
lib/types/array.rb,
lib/types/strings.rb,
lib/types/described.rb,
lib/types/type.rb

Defined Under Namespace

Classes: ArrayHeader, BinaryString, Described, Type, UTFString, UniformArray

collapse

NULL =
Type.new(Cproton::PN_NULL)
BOOL =
Type.new(Cproton::PN_BOOL)
UBYTE =
Type.new(Cproton::PN_UBYTE)
BYTE =
Type.new(Cproton::PN_BYTE)
USHORT =
Type.new(Cproton::PN_USHORT)
SHORT =
Type.new(Cproton::PN_SHORT)
UINT =
Type.new(Cproton::PN_UINT)
INT =
Type.new(Cproton::PN_INT)
CHAR =
Type.new(Cproton::PN_CHAR)
ULONG =
Type.new(Cproton::PN_ULONG)
LONG =
Type.new(Cproton::PN_LONG)
TIMESTAMP =
Type.new(Cproton::PN_TIMESTAMP)
FLOAT =
Type.new(Cproton::PN_FLOAT)
DOUBLE =
Type.new(Cproton::PN_DOUBLE)
DECIMAL32 =
Type.new(Cproton::PN_DECIMAL32)
DECIMAL64 =
Type.new(Cproton::PN_DECIMAL64)
DECIMAL128 =
Type.new(Cproton::PN_DECIMAL128)
UUID =
Type.new(Cproton::PN_UUID)
BINARY =
Type.new(Cproton::PN_BINARY)
STRING =
Type.new(Cproton::PN_STRING)
SYMBOL =
Type.new(Cproton::PN_SYMBOL)
DESCRIBED =
Type.new(Cproton::PN_DESCRIBED)
ARRAY =
Type.new(Cproton::PN_ARRAY)
LIST =
Type.new(Cproton::PN_LIST)
MAP =
Type.new(Cproton::PN_MAP)

Class Method Summary collapse

Class Method Details

.is_valid_utf?(value) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/types/strings.rb', line 22

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