What are the potential pitfalls of saving text files in Unicode format when working with PHP?

Saving text files in Unicode format when working with PHP can lead to potential pitfalls such as increased file size, compatibility issues with certain text editors or programs, and difficulties with handling special characters. To avoid these pitfalls, it is recommended to save text files in UTF-8 format, which is widely supported and ensures compatibility across different systems.

// Set the default encoding to UTF-8
mb_internal_encoding('UTF-8');

// Save text file in UTF-8 format
$file_content = "Hello, 你好, 안녕하세요";
file_put_contents('file.txt', $file_content);