Type %c: unknown format code

Description

pack() and unpack() convert data between a string representation and another. They both use a format string, passed as first argument, that specifies how the datat of the second argument are transformed. This format string uses a limited set of letters (and @) to express these transformation. Any other character is not recognized and produces this error.

The valid characters are : a, A, h, H, c, C, s, S, n, v, i, I, l, L, N, V, q, Q, J, P, f, g, G, d, e, E, x, X, Z, @

The format is checked after collecting the parameters, and before attempting the transformation.

Example

<?php

$array = unpack("z", $someData);

?>

Literal Examples

  • Type z: unknown format code

Solutions

  • Remove the unknown characters.

  • Fix the unknown character with a valid one.

See Also