I can't figure out how to get through this problem about UTF-8 conversion.
I can’t figure out how to get through this problem about UTF-8 conversion.
Here’s the steps:
- Open a ANSI text file (.txt or .php)
- The text does not have any special or accented characters
- Convert text into UTF-8 without BOM
- close file
- re-open same file: it’s again ANSI
What should I do in order to write PHP encoded as UTF-8?
P.S.: If text does have special or accented characters, it correctly encodes into UTF-8.
Version of notepad++ is 7.2.2 32bit
I don’t think you have a problem. I am fairly certain that if a file does not contain any special characters, then the ANSI and the UTF-8 without BOM versions are identical.
Under Settings->Preferences->New Document Encoding, select UTF-8 and also check the Apply to opened ANSI files box. Then when you open your “non-special” text file, NPP will tell you it is UTF-8. But, in reality, it is both UTF-8 and ANSI.
if you set the encoding to UTF-8 wihtout BOM, the file without any UTF-8 encoded chars will be physical the same like an ansi file. NPP will open the file in the default charset as there is nothing encoded in it.
Using UTF-8 with BOM will add 3 chars to the document that might apear in the page if you include files - maybe thats your reason to use without BOM.
i am adding following code in PHP:
<?php # UTF8 check: öäüßÖÄÜ にほんご
then save it as UTF-8 without BOM
NPP will identify the UTF-8 encoded japanese/german mix and recognise the document as UTF-8 without BOM.
please be aware that you need to mark the html-output as UTF-8 to avoid browsers to show rubbish.
header("Content-Type: text/html; charset=utf-8"); ?><!DOCTYPE html> <html> <head> <meta charset="UTF-8">