473,385 Members | 2,029 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,385 software developers and data experts.

notepad saves as ANSI, what about c#

Hi,

I produce a text file using my windows application written with c#.
--
System.Text.Encoding encOutput=null;
encOutput=System.Text.Encoding.UTF8;
StreamWriter sw=new StreamWriter(@"c:\a.txt",false, encOutput);
--
this UTF-8 file will be used to transfer data to another database's
import wizard. Unfortunately db that will import requires the file to be
saved as ANSI in notepad.

Always i have to open the UTF-8 encoded file with notepad and save it as
encoding ANSI in order not to have any problems.

How may i output a text file with an encoding that is compatible with
notepad's ANSI encoding...

Nov 16 '05 #1
2 20303
Hi,

UTF-8 and ANSI are very different beasts. Actually, I suppose the encoding
Notepad refers to as ANSI is the Windows codepage set for the user the
application runs under.
That is, if you create a file in Notepad containing Cyrillic letters, and
your codepage is 1251 (this is Windows codepage for the Russian language),
this file will be actually saved in the 1251 encoding.

So the bottom line is - if your file contains only English letters, numbers
and special characters such as @ or #, use the ASCII encoding. This should
be read by the DB import wizard without any hassle.
If your file will contain some non-English letters, you'd better use Unicode
and tell the DB import wizard to read the file in Unicode
Or, save the file in your current codepage encoding and ensure the same
encoding is used by the DB import wizard.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Ziver MALHASOGLU" <zi*********@hotmail.com> wrote in message
news:Oi*************@TK2MSFTNGP11.phx.gbl...
Hi,

I produce a text file using my windows application written with c#.
--
System.Text.Encoding encOutput=null;
encOutput=System.Text.Encoding.UTF8;
StreamWriter sw=new StreamWriter(@"c:\a.txt",false, encOutput);
--
this UTF-8 file will be used to transfer data to another database's
import wizard. Unfortunately db that will import requires the file to be
saved as ANSI in notepad.

Always i have to open the UTF-8 encoded file with notepad and save it as encoding ANSI in order not to have any problems.

How may i output a text file with an encoding that is compatible with
notepad's ANSI encoding...


Nov 16 '05 #2
Ziver MALHASOGLU <zi*********@hotmail.com> wrote:
I produce a text file using my windows application written with c#.
--
System.Text.Encoding encOutput=null;
encOutput=System.Text.Encoding.UTF8;
StreamWriter sw=new StreamWriter(@"c:\a.txt",false, encOutput);
--
this UTF-8 file will be used to transfer data to another database's
import wizard. Unfortunately db that will import requires the file to be
saved as ANSI in notepad.

Always i have to open the UTF-8 encoded file with notepad and save it as
encoding ANSI in order not to have any problems.

How may i output a text file with an encoding that is compatible with
notepad's ANSI encoding...


Just use Encoding.Default instead of Encoding.UTF8.

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

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

Similar topics

1
by: Trevor Fairchild | last post by:
I need to open an html document in notepad and save it using ANSI encoding. I can do this manually using notepad and File/Save-as, but is there a way to do this from VB. I can open a specific...
1
by: Roger | last post by:
I've got some MS-windows (XP only?) related questions; hopefully someone can give me some advise. 1) Is there some way to make notepad to become the front window when it is started from within...
3
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS...
5
by: RRD | last post by:
On a school network, using notepad or wordpad, running windows xp, the system is not allowing a save as FILE.html. it saves as .txt even when set to 'all files' in notepad and 'text only' in...
100
by: Roose | last post by:
Just to make a tangential point here, in case anyone new to C doesn't understand what all these flame wars are about. Shorthand title: "My boss would fire me if I wrote 100% ANSI C code" We...
1
by: jj | last post by:
How do I programatically default the encoding of my "Notepad" into ANSI. My application uses notepad to save some text. Some of the client computers have UTF as the default encoding in their...
9
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
3
by: Learning.Net | last post by:
How to read a Unicode data saved as ASCII in notepad file as txt ? I tried using streamReader but it is not showing Unicode data. eg. using (StreamReader sr = new StreamReader(test.txt) {...
6
by: The Bicycling Guitarist | last post by:
Okay my web site grew up and is moving to a non-Windows server, Unix. I am converting my static HTML/CSS files to Drupal content management system. The leading white spaces I use to indent text for...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.