What are some best practices for handling UTF-8 encoding and decoding in PHP when working with JSON data?

When working with JSON data in PHP, it's important to properly handle UTF-8 encoding and decoding to ensure that special characters are correctly preserved. One way to do this is by using the `json_encode` and `json_decode` functions with the `JSON_UNESCAPED_UNICODE` flag, which ensures that Unicode characters are not escaped. Additionally, setting the `default_charset` option in php.ini to UTF-8 can help with consistent encoding and decoding.

// Set default charset to UTF-8
ini_set('default_charset', 'UTF-8');

// Encode JSON data with UTF-8 support
$json_data = json_encode($data, JSON_UNESCAPED_UNICODE);

// Decode JSON data with UTF-8 support
$data = json_decode($json_data, true);