Sha256: 82acd7a3ba4f13449a2a16a54509124781c32c60580f19cd88ce8c8c6692cf8f
Contents?: true
Size: 706 Bytes
Versions: 82
Compression:
Stored size: 706 Bytes
Contents
require 'ably/models/message_encoders/base' module Ably::Models::MessageEncoders # Utf8 Encoder and Decoder # Uses encoding identifier 'utf-8' and encodes all JSON objects as UTF-8, and sets the encoding when decoding # class Utf8 < Base ENCODING_ID = 'utf-8' def encode(message, channel_options) # no encoding of UTF-8 required end def decode(message, channel_options) if is_utf8_encoded?(message) message[:data] = message[:data].force_encoding(Encoding::UTF_8) strip_current_encoding_part message end end private def is_utf8_encoded?(message) current_encoding_part(message).to_s.match(/^#{ENCODING_ID}$/i) end end end
Version data entries
82 entries across 82 versions & 2 rubygems