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.3k Views 2 Watching
    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.
    • Francesco MapelliF Offline
      Francesco Mapelli
      last edited by Francesco Mapelli

      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
      • Jim DaileyJ Offline
        Jim Dailey
        last edited by Jim Dailey

        @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
        • René W.R Offline
          René W.
          last edited by

          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors