public static string getString(Command cmd, bool forceunicode) { bool UnicodeCgm = forceunicode; Encoding enc = Encoding.ASCII; int length = cmd.ParamGet(cmd.CurrentArg++); int cb = cmd.ParamGet(cmd.CurrentArg++); if (cb == 0x1b || cb == 0 || UnicodeCgm) { enc = Encoding.Unicode; //cmd.CurrentArg += 2;//0x252f //length -= 2; UnicodeCgm = true; } else cmd.CurrentArg--; //return ""; if (length == 255) { length = makeUInt16(cmd); if ((length & (1 << 16)) != 0) { length = (length << 16) | makeUInt16(cmd); } } byte[] c = new byte[length]; for (int i = 0; i < length; i++) { if (cmd.CurrentArg >= cmd.ParamsLength) break; c[i] = (byte)makeByte(cmd); } return enc.GetString(c); }
public static string getFontList(Command c) { int count = 0, i = 0; while (i < c.ParamsLength) { count++; i += c.ParamGet(i) + 1; } string[] fontNames = new string[count]; count = 0; i = 0; while (i < c.ParamsLength) { int cl = c.ParamGet(i); if (cl == 0) break; byte[] a = new byte[cl]; for (int j = 0; j < cl; j++) a[j] = (byte)c.ParamGet(i + j + 1); fontNames[count] = BinaryUtil.AsString(a); count++; i += c.ParamGet(i) + 1; } return BinaryUtil.AsString(fontNames); }
public static byte makeChar(Command c) { return (byte)c.ParamGet(c.CurrentArg++); }
public static int makeByte(Command c) { return c.ParamGet(c.CurrentArg++); }
public static int makeUInt32(Command c) { return (char)(c.ParamGet(c.CurrentArg++) << 24) + (char)(c.ParamGet(c.CurrentArg++) << 16) + (char)(c.ParamGet(c.CurrentArg++) << 8) + (char)c.ParamGet(c.CurrentArg++); }
public static int makeUInt16(Command c) { ushort us = (ushort)((c.ParamGet(c.CurrentArg++) << 8) + c.ParamGet(c.CurrentArg++)); return us; ushort x = BitConverter.ToUInt16(c.Params, c.CurrentArg); c.CurrentArg += 2; return x; }
public static int makeSignedInt8(Command c) { return c.ParamGet(c.CurrentArg++); }
public static int makeSignedInt32(Command c) { return (c.ParamGet(c.CurrentArg++) << 24) + (c.ParamGet(c.CurrentArg++) << 16) + (c.ParamGet(c.CurrentArg++) << 8) + c.ParamGet(c.CurrentArg++); }
public static int makeSignedInt16(Command c) { return ((short)(c.ParamGet(c.CurrentArg++) << 8) + c.ParamGet(c.CurrentArg++)); short x = BitConverter.ToInt16(c.Params, c.CurrentArg); c.CurrentArg += 2; return x; }