Esempio n. 1
0
        public void Set(MutableString /*!*/ pattern, RubyRegexOptions options)
        {
            ContractUtils.RequiresNotNull(pattern, "pattern");

            // RubyRegexOptions.Once is only used to determine how the Regexp object should be created and cached.
            // It is not a property of the final object. /foo/ should compare equal with /foo/o.
            _options = options & ~RubyRegexOptions.Once;

            RubyEncoding encoding = RubyEncoding.GetRegexEncoding(options);

            if (encoding != null || pattern.Encoding.IsKCoding)
            {
                _pattern = MutableString.CreateBinary(pattern.ToByteArray(), encoding ?? RubyEncoding.Binary).Freeze();
            }
            else
            {
                _pattern = pattern.PrepareForCharacterRead().Clone().Freeze();
            }

            TransformPattern(encoding, options & RubyRegexOptions.EncodingMask);
        }
Esempio n. 2
0
 private void WriteStringValue(MutableString /*!*/ value)
 {
     byte[] data = value.ToByteArray();
     WriteInt32(data.Length);
     _writer.Write(data);
 }
Esempio n. 3
0
 // returns the number of bytes written to the stream:
 public int Write(MutableString /*!*/ value)
 {
     byte[] bytes = value.ToByteArray();
     return(Write(bytes, 0, bytes.Length));
 }