Click here to Skip to main content
15,915,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

I am reading the a HTML file through "StreamReader". How can I change the encoding of the HTML file from UTF-8 to various other encoding like hexadecimal & decimal entities.

All the suggestions are appreciated.

Look forward to hear your thoughts.

Warm regards,
Himanshu
Posted
Comments
Himanshu Kimni 7-Apr-15 5:38am    
Thanks for your comment. Basically I am looking forward for the entity conversion option through which I can convert the UTF-8 entities to hexadecimal/character/html entity.

1 solution

Firstly, UTF-8 is an encoding, but "hexadecimal" and "decimal" aren't: they are numeric formats, which may or may not be contained in your file.

If you mean that your file contains groups of numbers in a text format:
1234,1A7F
5678,00FF
...
And you want to convert them into numeric values that you can manipulate mathematically, then you have to separate each number, and parse it.
For hexadecimal values:
C#
string inp = "1A7F";
int x = Convert.ToInt32(inp, 16);

For decimal values:
C#
string inp = "1234";
int x = int.Parse(inp);

Or
C#
string inp = "1234";
int x;
if (int.TryParse(inp, out x))
    {
    ...
    }
 
Share this answer
 

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