How to convert ANSI-encoded file to UTF-8 using Notepad ++?

I have a website and I can send my Turkish characters to jQuery in Firefox, but Internet Explorer does not send my Turkish characters. I looked at the source file in notepad and this file's code page is ANSI.

When I convert it to UTF-8 without specification and close the file, the file again becomes ANSI when I reopen it.

How can I convert my file from ANSI to UTF-8?

+49
notepad ++ utf-8
Aug 31 '11 at 11:05
source share
3 answers

Regarding this part:

When I convert it to UTF-8 without the bom and close file, the file will again be ANSI when reopened.

The easiest solution is to completely fix the problem by properly setting up Notepad ++.

Try Settings Preferences New document Encoding select UTF-8 without specification and check Apply to opened ANSI files .

Thus, all open ANSI files will be processed as UTF-8 without specification.

For an explanation of what is going on, read the comments below this answer.

To fully learn about Unicode and UTF-8, read this excellent article by Joel Spolsky.

+59
Sep 14 2018-11-11T00:
source share

This may not be the answer you need, but I ran into a similar problem, so I decided to put it here.

I needed to convert 500 xml files to UTF8 via Notepad ++. Why Notepad ++? When I used the Encode to UTF8 option (many other converters use the same logic), it messed up all the special characters, so I had to use Convert to UTF8 explicitly.




Here are some simple steps to convert multiple files through Notepad ++ without the use of special characters (e.g. diacritics).

  • Launch Notepad ++, and then open the Plugins menu- > Plugin Manager-> Show Plugin Manager
  • Install Python Script . When the plugin is installed, restart the application.
  • Select the menu Plugins-> Python Script → New Script .
  • Select his name, and then go through the following code:

convertToUTF8.py

 import os import sys from Npp import notepad # import it first! filePathSrc="C:\\Users\\" # Path to the folder with files to convert for root, dirs, files in os.walk(filePathSrc): for fn in files: if fn[-4:] == '.xml': # Specify type of the files notepad.open(root + "\\" + fn) notepad.runMenuCommand("Encoding", "Convert to UTF-8") # notepad.save() # if you try to save/replace the file, an annoying confirmation window would popup. notepad.saveAs("{}{}".format(fn[:-4], '_utf8.xml')) notepad.close() 

Finally run Script

+39
22 '13 at 10:26
source share

If your file does not contain characters other than ASCII (code pages 128 and above), UTF-8 without specification is the same as ASCII, byte for byte - therefore Notepad ++ is mistaken.

What you need to do is specify the character encoding when serving the AJAX response - for example, with PHP, you would do this:

 header('Content-Type: application/json; charset=utf-8'); 

The important part is to specify the encoding with each JS response - otherwise IE will return to the default encoding for the user system, which is an error most of the time.

+13
Aug 31 '11 at 11:12
source share



All Articles