473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Possible Text Encoding Question

Hey all.
I've seen something that confuses me a bit, and was wondering if
someone could shed some light on the issue.
I have an XML file as an embedded resource in a C# Windows Forms
application. The File is taken directly from a file on the desktop.
I load it into a stream...
....
Assembly a = Assembly.GetExecutingAssembly();
Stream resStream = a.GetManifestResourceStream(resourceName);
....
Read it into an XML document
....
XmlDocument doc = new XmlDocument();
doc.Load(resStream);
....
And write it back out without changes.
....
doc.Save(xmlFileName);
....
The file is written, and when opening the files in notepad, they look
identical.
However, the new file is half the size of the original.
Anyone know why this is or how I can correct this?
Thanks for your time.
-Mezz

Nov 16 '05 #1
1 1246
> Hey all.

I've seen something that confuses me a bit, and was wondering if
someone could shed some light on the issue.

I have an XML file as an embedded resource in a C# Windows Forms
application. The File is taken directly from a file on the desktop.

I load it into a stream...

....
Assembly a = Assembly.GetExecutingAssembly();
Stream resStream = a.GetManifestResourceStream(resourceName);
....
Read it into an XML document

....
XmlDocument doc = new XmlDocument();
doc.Load(resStream);
....
And write it back out without changes.

....
doc.Save(xmlFileName);
....
The file is written, and when opening the files in notepad, they look
identical.
However, the new file is half the size of the original.
Anyone know why this is or how I can correct this?
Thanks for your time.
-Mezz


Well, your subject may be correct. What encoding was used for the original
file? What encoding are you using for the new file? (If you don't specify
one then the default should be UTF8)

If, on the off chance, the original file was encoded as UTF16 and the contents
really only needed UTF8, you could see the file size change you mention.

You can check the encoding by looking at the first 2 or 4 bytes of the file.
If it is unicode, they should match one of these:
http://msdn.microsoft.com/library/de...icode_42jv.asp

Nov 16 '05 #2

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

Similar topics

1
by: David Thomas | last post by:
Hi there, a while ago, I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with...
0
by: QWERTY | last post by:
--------------Boundary-00=_O5I3QL80000000000000 Content-Type: Multipart/Alternative; boundary="------------Boundary-00=_O5I3LVC0000000000000" --------------Boundary-00=_O5I3LVC0000000000000...
2
by: Mark | last post by:
Sorry about the last... Anyway, here's the question: I've been working on some C# routines to process strings in and out of various encodings. The hope is that I can just let the user type in...
3
by: Cherif Diallo | last post by:
Hi I have a trivial question for the experts. I would lilke to read be able to read a text file that could contain french characters with accents. I'm opening the file with the...
4
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
10
by: Oscar Thornell | last post by:
Hi, I generate and temporary saves a text file to disk. Later I upload this file to Microsoft MapPoint (not so important). The file needs to be in UTF-8 encoding and I explicitly use the...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
4
by: George | last post by:
Hi, I am puzzled by the following and seeking some assistance to help me understand what happened. I have very limited encoding knowledge. Our SAP system writes out a text file which includes...
4
by: =?ISO-8859-1?Q?Nordl=F6w?= | last post by:
How do I efficiently determine which possible encoding(s) a given text is in? Can I use the iconv.h api somehow? Thanks in advance, Nordlöw
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.