encode basic types