There is a better approach - the pj_cstr function, described as "Create constant string from normal C string".