Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
The ANSI value of Pi is 182,ƒ is 131.
I am reading a XMl file which contains a lots of ANSI values i have to display as character i.e if i pass 131 it should give me "ƒ" character.

Thanks in advance
Posted
Comments
Afzaal Ahmad Zeeshan 16-Jul-15 0:24am    
You are right, it indeed is a standard-based value.

Ok, did you try to cast the value? Try using this,

char character = (char) 131; // may provide you with ƒ


But I am not sure.
Never mind!

You need to use Encoding class and get the encoding for Encoding.GetEncoding(1252); and use it as the encoding to get integer values or characters. I am still not sure why you are using this.
Sergey Alexandrovich Kryukov 16-Jul-15 0:56am    
Thank you for recognizing this obsolete encoding. Please see my answer. I'm afraid it will again reduce to discussion what Unicode is...
—SA
Starlene 16-Jul-15 0:32am    
No it is not working

1 solution

Thanks to the comment to the question by Afzaal, I realized that you probably mean obsolete encoding Windows 1252: https://en.wikipedia.org/wiki/Windows-1252[^].

And 182=0xb6 is the "pilcrow sign" ('¶') in both "ANSI" and Unicode; and 131=0x83 is "no break here" in Unicode and undefined in what is usually referred to as "ANSI".

Here we are coming to a delicate point. "ANSI", as a character set, is not something certain. This "term" may refer to different things. Please read about it: https://en.wikipedia.org/wiki/ANSI_character_set[^].

At the same time, the term "ANSI" for the character was extensively used as Windows-specific jargon word in pre-Unicode Windows versions, and later renamed as a term using for legacy non-Unicode Windows character encodings supported by modern versions of Windows for backup compatibility, to certain extent. See the reference above and the references article and MSDN documentation.

I have to note that Windows is full of confusing jargon words not meeting any standard. Even the term "Unicode" is routinely used in jargon sense, as the encoding UTF-16LE, which is the internal encoding use for representing Unicode characters/strings in memory, which provides no justification to call it "Unicode". Other UTFs are called by their standard names, but rarely mentioning endianness.
In contrast to that, .NET is fully based on Unicode standard which is also the main standard for XML (which supports many character sets), and hence WPF and everything else. You should understand that Unicode is not encoding. Unicode encodings are standardized as UTFs which support the same character repertoire, without any exclusions; and XML character entities have nothing to do with UTFs, they directly specify Unicode character points.

Conclusion: You need to get rid of the obsolete encoding and transcode everything in Unicode, and only to Unicode. In .NET, it can be done using the class System.Text.Encoding (its use is pretty obvious from MSDN documentation):
https://msdn.microsoft.com/en-us/library/system.text.encoding%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v4
Comments
Starlene 16-Jul-15 1:39am    
i kn this will give me the result but dont have idea how i will get the Picrown sing using this namespace.Can you help me providing the code
Sergey Alexandrovich Kryukov 16-Jul-15 1:44am    
Now you need Picrown sing... It's weird, before you wanted Windows-1252 π...
So, what code? Get where? First, you need to understand what you really want...
—SA
[no name] 19-Jul-15 17:39pm    
this idiot Sergey Alexandrovich Kryukov is posting whatever he wants, complete bullsh*t. Get away from here dirty ship!
Starlene 16-Jul-15 1:49am    
plz check this link http://www.globaliconnect.com/excel/index.php?option=com_content&view=article&id=116:ascii-code-extended-ascii-characters-8-bit-system-and-ansi-code&catid=78&Itemid=474
i want all the Extended ASCII printing character chart.If i will pass the value decimal value i will get the character
Sergey Alexandrovich Kryukov 16-Jul-15 2:07am    
Extended ASCII is also not something certain: https://en.wikipedia.org/wiki/Extended_ASCII.
Just convert everything to Unicode. In worst case, if you don't have exact Encoding class (derived from System.Text.Encoding) supporting your variant of "Extended ASCII", just have you own conversion table, which would be just the array of characters.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900