Beispiel #1
0
        static string GetUtf8String(GetStringHandler handler)
        {
            byte b      = 0;
            int  length = handler(ref b, 0);
            var  buffer = new byte[length];

            handler(ref buffer[0], length);
            return(Encoding.UTF8.GetString(buffer, 0, (int)length - 1));
        }
Beispiel #2
0
        public string OnGetStringEvent()
        {
            string           ret            = null;
            GetStringHandler getStringEvent = GetStringEvent;

            if (getStringEvent != null)
            {
                ret = getStringEvent();
            }
            return(ret);
        }
Beispiel #3
0
        static string GetUtf16String(GetStringHandler handler, int lengthUnit, bool lengthIncludesTerminator)
        {
            byte b      = 0;
            int  length = handler(ref b, 0);
            var  buffer = new byte[length * lengthUnit];

            handler(ref buffer[0], length);
            length *= lengthUnit;
            if (lengthIncludesTerminator)
            {
                length -= 2;
            }
            return(Encoding.Unicode.GetString(buffer, 0, length));
        }
Beispiel #4
0
        private static string GetUtf8String(GetStringHandler handler)
        {
            byte b      = 0;
            var  length = handler(ref b, 0);

            if (length == 0)
            {
                return(string.Empty);
            }

            var buffer = new byte[length];

            handler(ref buffer[0], length);
            return(Encoding.UTF8.GetString(buffer, 0, length - 1));
        }