예제 #1
0
            public static char ToValue(byte[] table, int index)
            {
                UnionChar bt = new UnionChar();

                bt.SetBytes(table, index);
                return(bt.value);
            }
예제 #2
0
            public static byte[] ToBytes(char val)
            {
                UnionChar bt = new UnionChar();

                bt.value = val;
                return(bt.bytes);
            }
예제 #3
0
            // Ex string : size = sizeof(short) + sizeof(char) * num
            public static byte[] ToBytes(string val)
            {
                short byteSize = (short)(val.Length * sizeof(char));

                byte[] bt  = new byte[byteSize + sizeof(short)];
                int    idx = 0;

                // Set ByteSize field
                UnionShort uniSize = new UnionShort();

                uniSize.value = byteSize;
                bt[idx++]     = uniSize.b0;
                bt[idx++]     = uniSize.b1;

                // Set String field
                UnionChar uniCh = new UnionChar();

                foreach (char ch in val.ToCharArray())
                {
                    uniCh.value = ch;
                    foreach (byte b in uniCh.bytes)
                    {
                        bt[idx++] = b;
                    }
                }

                return(bt);
            }
예제 #4
0
 public static byte[] ToBytes(char val)
 {
     return(UnionChar.ToBytes(val));
 }
예제 #5
0
 public static int ToValue(out char ret, byte[] bytes, int index)
 {
     ret = UnionChar.ToValue(bytes, index);
     return(UnionChar.Size);
 }