Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 158313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:39:34+00:00 2026-05-11T10:39:34+00:00

I am reading files in various formats and languages and I am currently using

  • 0

I am reading files in various formats and languages and I am currently using a small encoding library to take attempt to detect the proper encoding (http://www.codeproject.com/KB/recipes/DetectEncoding.aspx).

It’s pretty good, but it still misses occasionally. (Multilingual files)

Most of my potential users have very little understanding of encoding (the best I can hope for is ‘it has something to do with characters’) and are very unlikely to be able to choose the right encoding in a list, so I would like to let them cycle through different encodings until the right one is found just by clicking on a button.

Display problems? Click here to try a different encoding! (Well that’s the concept anyway)

What would be the best way to implement something like that?


Edit: Looks like I didn’t express myself clearly enough. By ‘cycling through the encoding’, I don’t mean ‘how to loop through encodings?’

What I meant was ‘how to let the user try different encodings in sequence without reloading the file?’

The idea is more like this: Let’s say the file is loaded with the wrong encoding. Some strange characters are displayed. The user would click a button ‘Next encoding’ or ‘previous encoding’, and the string would be converted in a different encoding. The user just need to keep clicking until the right encoding is found. (whatever encoding looks good for the user will do fine). As long as the user can click ‘next’, he has a reasonable chance of solving his problem.

What I have found so far involves converting the string to bytes using the current encoding, then converting the bytes to the next encoding, converting those bytes into chars, then converting the char into a string… Doable, but I wonder if there isn’t an easier way to do that.

For instance, if there was a method that would read a string and return it using a different encoding, something like ‘render(string, encoding)’.


Thanks a lot for the answers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:39:35+00:00Added an answer on May 11, 2026 at 10:39 am

    Read the file as bytes and use then the Encoding.GetString Method.

            byte[] data = System.IO.File.ReadAllBytes(path);          Console.WriteLine(Encoding.UTF8.GetString(data));         Console.WriteLine(Encoding.UTF7.GetString(data));         Console.WriteLine(Encoding.ASCII.GetString(data)); 

    So you have to load the file only one time. You can use every encoding based on the original bytes of the file. The user can select the correct one und you can use the result of Encoding.GetEncoding(…).GetString(data) for further processing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading image files in Java using java.awt.Image img = Toolkit.getDefaultToolkit().createImage(filePath); On some
I am trying to import various pipe delimited files using php 5.2 into a
There are a lot of examples on the internet of reading files but I
reading excel files from C# working well in 32 bit version server. It is
I am reading log files but not all lines want to be processed straight
I'm reading all the files in a single directory and I want to filter
I have a problem with reading some gml files in c#. My files do
I'm starting a project which requires reading outlook msg files in c#. I have
Ok, I am reading in dat files into a byte array. For some reason,
Possible Duplicate: Reading/Writing MS Word files in Python I know there are some libraries

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.