Sanitize non utf-8 values when json encoding a record to be written
Cache results of function_exists
Merge branch 'rfink-bug/jsonencodewarning'