Skip to main content
Inspiring
June 3, 2008
Question

Handy four char code decoder

  • June 3, 2008
  • 1 reply
  • 1339 views
Hi,
as many of you have seen, Adobe uses 4 character codes quite a bit (error codes from functions, parameters to actions), encoded as an integer. Here is a helpful bit of javascript to convert this stuff:
http://www.avenza.com/convert4cc.html

Primarily, I use it to decode parameters to actions after saving an action set to a file (I think that topic has come up on the forum recently).

Hopefully someone else finds this helpful,
Cheers!

Garvan.
This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
June 5, 2008
In a similar vein, here's an inline function that will convert the SPErr (or AIErr) into it's four-character human-readable code:

] inline void ConvertSPErr(const SPErr error, char* buffer)
] {
] static const int kErrorByteSize = sizeof(SPErr);
] static const int kCharBitCount = sizeof(char) * 8;
] static const int kBaseMask = 0xff;
] int mask = 0;
]
] for (int i = 0; i < kErrorByteSize; i++) {
] mask = kBaseMask << (kCharBitCount * i);
] int value = error & mask;
] value = value >> (kCharBitCount * i);
] buffer[kErrorByteSize - i - 1] = (char)value;
] }
]
] buffer[kErrorByteSize] = 0;
] }