gbm: Move gbm_format_canonicalize() to the core.