Apache.NMS.Util.EndianBinaryWriter.encodeUTF8toBuffer C# (CSharp) Method

encodeUTF8toBuffer() private static method

private static encodeUTF8toBuffer ( char chars, byte buffer ) : void
chars char
buffer byte
return void
        private static void encodeUTF8toBuffer(char[] chars, byte[] buffer)
        {
            int c = 0;
            int count = 0;

            for(int i = 0; i < chars.Length; i++)
            {
                c = chars[i];
                if((c >= 0x0001) && (c <= 0x007F))
                {
                    buffer[count++] = (byte) c;
                }
                else if(c > 0x07FF)
                {
                    buffer[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
                    buffer[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
                    buffer[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
                }
                else
                {
                    buffer[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
                    buffer[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
                }
            }
        }