Apache.NMS.ActiveMQ.OpenWire.BaseDataStreamMarshaller.TightMarshalString1 C# (CSharp) Méthode

TightMarshalString1() protected méthode

protected TightMarshalString1 ( String value, BooleanStream bs ) : int
value String
bs BooleanStream
Résultat int
        protected virtual int TightMarshalString1(String value, BooleanStream bs)
        {
            bs.WriteBoolean(value != null);
            if (value != null)
            {
                int strlen = value.Length;

                int utflen = 0;
                int c = 0;
                bool isOnlyAscii = true;
                char[] charr = value.ToCharArray();
                for (int i = 0; i < strlen; i++)
                {
                    c = charr[i];
                    if ((c >= 0x0001) && (c <= 0x007F))
                    {
                        utflen++;
                    }
                    else if (c > 0x07FF)
                    {
                        utflen += 3;
                        isOnlyAscii = false;
                    }
                    else
                    {
                        isOnlyAscii = false;
                        utflen += 2;
                    }
                }

                if (utflen >= Int16.MaxValue)
                    throw new IOException("Encountered a String value that is too long to encode.");

                bs.WriteBoolean(isOnlyAscii);
                return utflen + 2;
            }
            else
            {
                return 0;
            }
        }