473,654 Members | 3,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect characterset of text file

Hi,

I can't find out, how to detect the characterset of a text file. Orders I
receive by mail have the same structure, but are created on different
systems, like DOS, Windows, Linux. So the characterset may be different.
After importing these file, the results may be different, because of the
fact, that characters like ä, à... of a DOS-created file are not the same
compared to a Windows-created file.

Do you know a way how to detect the characterset of a text file in order to
convert this file correctly?

Thank's and regards

Jari
Nov 16 '05 #1
3 3313
Hi Jari,

For simple text file, as far as I know, there is information about the characterset used.
You have to either guess the characterset or try to find out from who or what made the text file.

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Hi Morten,

I could map e.g. sender of text file to characterset used by this sender.
Would prefer a solution with detection of characterset: sender could change
his PC, OS and this would mean, that definition would have to be changed as
well.

Thank's - Jari

"Morten Wennevik" <Mo************ @hotmail.com> schrieb im Newsbeitrag
news:opsc9zknpw klbvpo@stone...
Hi Jari,

For simple text file, as far as I know, there is information about the characterset used. You have to either guess the characterset or try to find out from who or what made the text file.
--
Happy coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #3
Jaroslav Jakes <jj****@eh-services.ch> wrote:
I could map e.g. sender of text file to characterset used by this
sender. Would prefer a solution with detection of characterset:
sender could change his PC, OS and this would mean, that definition
would have to be changed as well.


The problem is that two users could send two identical files, but mean
entirely different things by them. There are some character encodings
which can be detected as the *likely* encoding for a file, but it'll
never be 100% accurate.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3300
by: Jason Manfield | last post by:
Why does HttpWebResponse.CharacterSet always return ISO-8859-1? I am accessing a Chinese Web site (http://cn.yahoo.com) -- View Source in IE shows the character set to be "gb2312", but the HttpWebResponse shows it to be ISO-8859-1. Websites like www.cnn.com also show the character set to ISO-8859-1 Here is the code snippet: string pageAddress = "http://cn.yahoo.com"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pageAddress);
7
7418
by: Richard Bond | last post by:
Hi Is there anyway to change the characterset/codepage of a specific textbox on a winform. I have read in a "chinese traditional big5" file into memory using a streamreader with the appropriate codepage SR = New StreamReader(TBLFilename, System.Text.Encoding.GetEncoding(Cube.CodePage))
2
1923
by: eBob.com | last post by:
I've got the basics of an XML ini file working. I.E. I can stash away and retrieve user preferences. (Code below.) But how do I handle a new preference? Say I have A and B. And then I invent C. The first time the new version with C is run the XML file will not have a value for C. How do I detect that case? Somewhere I got the impression that I could use IsNull, but I was unable to find an example which I could apply to my code. My...
13
27974
by: Michal | last post by:
Hello, is there any way how to detect string encoding in Python? I need to proccess several files. Each of them could be encoded in different charset (iso-8859-2, cp1250, etc). I want to detect it, and encode it to utf-8 (with string function encode). Thank you for any answer Regards Michal
4
2758
by: Marc Scheuner | last post by:
Folks, I have a text file which contains some XML. In its XML header, it claims to be of UTF-8 encoding - however, it's really not, it's a ANSI / Windows-1252 / ISO-8859-1 encoding. Trouble is: when I deserialize objects from that file, all the German umlauts and other special characters get dropped, some even cause deserialization errors.
6
6992
by: Leon_Amirreza | last post by:
My Page contains this: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> i used this code to retrieve the page: HttpWebResponse webresp = (HttpWebResponse)(webrq.GetResponse()); the value of the some properties of webreps are as follows:
8
2673
by: Erwin Moller | last post by:
Hi group, I could use a bit of guidance on the following matter. I am starting a new project now and must make some decisions regarding encoding. Environment: PHP4.3, Postgres7.4.3 I must be able to receive forminformation and store that in a database and later produce it on screen on the client (just plain HTML).
4
1892
by: sid | last post by:
Can someone tell me how to detect "Action Cancelled" page with out polling. I have a frame set and I want to make sure the other frame is displaying what it is supposed to without polling. For some reason the page does not file OnError or OnLoad events. Any help is appreciated. Thanks
36
5372
by: Don | last post by:
I wrote an app that alerts a user who attempts to open a file that the file is currently in use. It works fine except when the file is opened by Notepad. If a text file is opened, most computers are configured to use Notepad to open the file by default and if they are configured to use Notepad by default I want it to remain that way rather than retrieve the text into my app or force the user to use another app to read the file. I'm...
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8494
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.