[php-src] Issue #13935: JSON Error Message: Malformed UTF-8 characters, possibly incorrectly encoded

From: Date: Wed, 10 Apr 2024 14:40:17 +0000
Subject: [php-src] Issue #13935: JSON Error Message: Malformed UTF-8 characters, possibly incorrectly encoded
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246733@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13935 Author: bquimby1 ### Description The following code: if ( $json = json_encode($o->exifobj) ) { $photosjsonarray[] = $json; } else { $this->writeFetchLog(sprintf("%s did not produce JSON at count %d - %s",$filename,$cnt,json_last_error_msg())); continue; } Resulted in this output: (for only 1 element) Malformed UTF-8 characters, possibly incorrectly encoded But I expected this output instead: a well formed json object -It appears that in some cases (a single one for me) jason_encode() doesn't like the degree symbol (macOs Option+Shift+8). The symbol is embedded (by me), in a file read by a Perl script and exiftool, and inserted into the exif metadata in a photo. In this particular photo I use the symbol in 2 separate lines of text that feed the exif metadata. There are no hidden characters in the file (vim :set list). json_encode() doesn't fail on data read from 1 line in the file but does on the other. No other software (used by me) has ever failed to interpret the degree symbol. **No problem with this line:** +Caption="+First Winter hike of the season. 20°F during the hike and dropping. I did the four mile Hardwood Swamp Loop at Black Creek Park." **Problem with this line:** +Caption="+First Winter hike of the season. 20°F during the hike and dropping. This little bird posed nicely. There wasn't much wildlife because of the human traffic." ### PHP Version PHP 8.1.27 ### Operating System macOS Sonoma 14.4.1

« previous php.bugs (#246733) next »