• Login
Community
  • Login

I can't figure out how to get through this problem about UTF-8 conversion.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 3 Posters 2.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F
    Francesco Mapelli
    last edited by Francesco Mapelli Jan 12, 2017, 4:24 PM Jan 12, 2017, 4:22 PM

    Hi everybody,
    I can’t figure out how to get through this problem about UTF-8 conversion.
    Here’s the steps:

    1. Open a ANSI text file (.txt or .php)
    2. The text does not have any special or accented characters
    3. Convert text into UTF-8 without BOM
    4. close file
    5. 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

    1 Reply Last reply Reply Quote 0
    • J
      Jim Dailey
      last edited by Jim Dailey Jan 12, 2017, 5:17 PM Jan 12, 2017, 5:17 PM

      @Francesco-Mapelli

      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.

      1 Reply Last reply Reply Quote 0
      • R
        René W.
        last edited by Jan 18, 2017, 9:20 AM

        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">
        
        1 Reply Last reply Reply Quote 0
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors