ANSI encoding is a slightly generic term used to refer to the standard code page on a system, usually Windows. It is more properly referred to as Windows-1252 on Western/U.S. systems. (It can represent certain other Windows code pages on other systems.) This is essentially an extension of the ASCII character set in that it includes all the ASCII characters with an additional 128 character codes. This difference is due to the fact that "ANSI" encoding is 8-bit rather than 7-bit as ASCII is (ASCII is almost always encoded nowadays as 8-bit bytes with the MSB set to 0). See the article for an explanation of why this encoding is usually referred to as ANSI.
The name "ANSI" is a misnomer, since it doesn't correspond to any actual ANSI standard, but the name has stuck. ANSI is not the same as UTF-8.
Answer from Noldorin on Stack OverflowANSI encoding is a slightly generic term used to refer to the standard code page on a system, usually Windows. It is more properly referred to as Windows-1252 on Western/U.S. systems. (It can represent certain other Windows code pages on other systems.) This is essentially an extension of the ASCII character set in that it includes all the ASCII characters with an additional 128 character codes. This difference is due to the fact that "ANSI" encoding is 8-bit rather than 7-bit as ASCII is (ASCII is almost always encoded nowadays as 8-bit bytes with the MSB set to 0). See the article for an explanation of why this encoding is usually referred to as ANSI.
The name "ANSI" is a misnomer, since it doesn't correspond to any actual ANSI standard, but the name has stuck. ANSI is not the same as UTF-8.
Technically, ANSI should be the same as US-ASCII. It refers to the ANSI X3.4 standard, which is simply the ANSI organisation's ratified version of ASCII. Use of the top-bit-set characters is not defined in ASCII/ANSI as it is a 7-bit character set.
However years of misuse of the term by the DOS and subsequently Windows community has left its practical meaning as “the system codepage of whatever machine is being used”. The system codepage is also sometimes known as ‘mbcs’, since on East Asian systems that can be a multiple-byte-per-character encoding. Some code pages can even use top-bit-clear bytes as trailing bytes in a multibyte sequence, so it's not even strict compatible with plain ASCII... but even then, it's still called “ANSI”.
On US and Western European default settings, “ANSI” maps to Windows code page 1252. This is not the same as ISO-8859-1 (although it is quite similar). On other machines it could be anything else at all. This makes “ANSI” utterly useless as an external encoding identifier.
How to convert .txt to ANSI encoding
UTF-8 and ANSI encoding issue
ENCODING PROBLEM- Reading an ANSI File
Windows 10 1903) How to change Default Encoding UTF-8 to ANSI In Notepad?
What is the difference between Windows-1252 and ANSI encoding?
See below. In practice it probably won't make much difference to your conversion.
If you keep a copy of the original file then you can always apply a different conversion if necessary.
Having said that there are ways of converting UTF-8 to ANSI.
Windows-1252
This character encoding is a superset of ISO 8859-1 in terms of printable characters, but differs from the IANA's ISO-8859-1 by using displayable characters rather than control characters in the 80 to 9F (hex) range. Notable additional characters include curly quotation marks and all the printable characters that are in ISO 8859-15. It is known to Windows by the code page number 1252, and by the IANA-approved name "windows-1252".
...
Historically, the phrase "ANSI Code Page" (ACP) is used in Windows to refer to various code pages considered as native. The intention was that most of these would be ANSI standards such as ISO-8859-1. Even though Windows-1252 was the first and by far most popular code page named so in Microsoft Windows parlance, the code page has never been an ANSI standard. Microsoft explains, "The term ANSI as used to signify Windows code pages is a historical reference, but is nowadays a misnomer that continues to persist in the Windows community.
Source Windows-1252
Note that is spite of the above statement by Microsoft they still call Windows 1252 "ANSI":
Source Code Page 1252 Windows Latin 1 (ANSI)
Are Windows-1252 and ANSI the same thing?
– Yes, for Western European languages, they are identically the same encodings. 1
For other natural languages, see my table at the end of this answer.
Unfortunately, the Wikipedia pages on the topic, this and
this,
are riddled with confusing statements and unreferenced claims.
You are much better off going directly to
one of the sources that Wikipedia does reference.
It was written in May 2002 and says :
The term “ANSI” as used to signify Windows code pages is a historical reference, but is nowadays a misnomer that continues to persist in the Windows community. The source of this comes from the fact that the Windows code page 1252 was originally based on an ANSI draft, which became ISO Standard 8859-1. However, in adding code points to the range reserved for control codes in the ISO standard, the Windows code page 1252 and subsequent Windows code pages originally based on the ISO 8859-x series deviated from ISO. To this day [May 2002], it is not uncommon to have the development community, both within and outside of Microsoft, confuse the 8859-1 code page with Windows 1252, as well as see “ANSI” or “A” used to signify Windows code page support.
References
- Charts showing the Windows-1252 character set | Section 4
- Post containing a table of all ten Windows code pages
- Windows-1252 | Wikipedia
- ISO/IEC 8859-1 | Wikipedia
- Unicode and Windows XP | Cathy Wissink, Microsoft
1 For charts displaying the Windows-1252 character set, see this post, Section 4.
I have a script I wrote in PowerShell ISE v5.1 It is reading a tab delimited file that Notepad++ shows as "ANSI". The file contains apostrophes that is not converting properly. The character is ’ not the standard ', The hex value I think is 2019. When running the OutputEncoding command it shows Western European (Windows). Any thoughts on how to read this file properly?
$File_streamreader = New-Object System.IO.StreamReader($myfile)
While (($readeachline = $File_streamreader.Readline()) -ne $null) {....Thank you for your help.
ANSI means more or less nothing --- the most probable candidate for your encoding is Windows-1252. You can convert the file with
iconv -f WINDOWS-1252 -t utf8 < filein.txt > fileout.txt
but remember, most encodings (read the linked article if you are not sure about what that mean) can't be reliably guessed, so you need to know the exact encoding to give sense to your data.
From the comments it seems that you are most probably looking for some Arabic encoding --- in that case check WINDOWS-1256.
The list of available encodings for iconv is on github, or you can find it with the command
iconv --list
Notice that just at the start of the list there are a bunch of "ANSI"-like encodings.
If you don't want to convert it as mentioned in Rmano's answer, you may use Geany or Kate to read/edit them ar they are, default Arabic encoding in Windows is CP-1256 (WINDOWS-1256). Just keep in mind that switching to UTF-8 is recommended over all. It is supported by Notepad++ and Windows default note editor.
Geany
sudo apt-get install geany

Kate
sudo apt-get install kate

